From f5862f12df0c5d3c16ebc21272cc0d56a37fb33b Mon Sep 17 00:00:00 2001 From: Navneet Anand <1629076@kiit.ac.in> Date: Thu, 11 Dec 2025 18:26:22 +0530 Subject: [PATCH 1/4] Solution for the Annalyn's Infiltration Problem on Exercism. --- .../src/main/java/AnnalynsInfiltration.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/exercises/concept/annalyns-infiltration/src/main/java/AnnalynsInfiltration.java b/exercises/concept/annalyns-infiltration/src/main/java/AnnalynsInfiltration.java index 97a724d39..6d5bb7d84 100644 --- a/exercises/concept/annalyns-infiltration/src/main/java/AnnalynsInfiltration.java +++ b/exercises/concept/annalyns-infiltration/src/main/java/AnnalynsInfiltration.java @@ -1,17 +1,21 @@ class AnnalynsInfiltration { - public static boolean canFastAttack(boolean knightIsAwake) { - throw new UnsupportedOperationException("Please implement the (static) AnnalynsInfiltration.canFastAttack() method"); + public static boolean canFastAttack(boolean knightIsAwake){ + // throw new UnsupportedOperationException("Please implement the (static) AnnalynsInfiltration.canFastAttack() method"); + return !knightIsAwake; } public static boolean canSpy(boolean knightIsAwake, boolean archerIsAwake, boolean prisonerIsAwake) { - throw new UnsupportedOperationException("Please implement the (static) AnnalynsInfiltration.canSpy() method"); + // throw new UnsupportedOperationException("Please implement the (static) AnnalynsInfiltration.canSpy() method"); + return ((knightIsAwake || archerIsAwake) || prisonerIsAwake); } public static boolean canSignalPrisoner(boolean archerIsAwake, boolean prisonerIsAwake) { - throw new UnsupportedOperationException("Please implement the (static) AnnalynsInfiltration.canSignalPrisoner() method"); + // throw new UnsupportedOperationException("Please implement the (static) AnnalynsInfiltration.canSignalPrisoner() method"); + return !archerIsAwake && prisonerIsAwake; } public static boolean canFreePrisoner(boolean knightIsAwake, boolean archerIsAwake, boolean prisonerIsAwake, boolean petDogIsPresent) { - throw new UnsupportedOperationException("Please implement the (static) AnnalynsInfiltration.canFreePrisoner() method"); + // throw new UnsupportedOperationException("Please implement the (static) AnnalynsInfiltration.canFreePrisoner() method"); + return (prisonerIsAwake && !archerIsAwake && !knightIsAwake) || (!archerIsAwake && petDogIsPresent); } -} +} \ No newline at end of file From 1b99df00d9773d0e47d22baf471f1c313a28c2aa Mon Sep 17 00:00:00 2001 From: Navneet Anand <1629076@kiit.ac.in> Date: Thu, 11 Dec 2025 18:32:21 +0530 Subject: [PATCH 2/4] Solution for the Bird Watcher Problem on Exercism. This learning exercise helped evolve your knowledge of Arrays, For-Each Loops, and For Loops. --- .../src/main/java/BirdWatcher.java | 43 ++++++++++++++++--- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/exercises/concept/bird-watcher/src/main/java/BirdWatcher.java b/exercises/concept/bird-watcher/src/main/java/BirdWatcher.java index c19dd38e6..23efc7b8f 100644 --- a/exercises/concept/bird-watcher/src/main/java/BirdWatcher.java +++ b/exercises/concept/bird-watcher/src/main/java/BirdWatcher.java @@ -7,26 +7,55 @@ public BirdWatcher(int[] birdsPerDay) { } public int[] getLastWeek() { - throw new UnsupportedOperationException("Please implement the BirdWatcher.getLastWeek() method"); + // throw new UnsupportedOperationException("Please implement the BirdWatcher.getLastWeek() method"); + int[] birdCount = new int[] {0,2,5,3,7,8,4}; + return birdCount; } public int getToday() { - throw new UnsupportedOperationException("Please implement the BirdWatcher.getToday() method"); + // throw new UnsupportedOperationException("Please implement the BirdWatcher.getToday() method"); + return birdsPerDay[birdsPerDay.length-1]; } public void incrementTodaysCount() { - throw new UnsupportedOperationException("Please implement the BirdWatcher.incrementTodaysCount() method"); + /// throw new UnsupportedOperationException("Please implement the BirdWatcher.incrementTodaysCount() method"); + birdsPerDay[birdsPerDay.length-1] += 1; } public boolean hasDayWithoutBirds() { - throw new UnsupportedOperationException("Please implement the BirdWatcher.hasDayWithoutBirds() method"); + // throw new UnsupportedOperationException("Please implement the BirdWatcher.hasDayWithoutBirds() method"); + boolean noBird = false; + for(int count : birdsPerDay){ + if (count == 0){ + noBird = true; + } + + } + return noBird; } public int getCountForFirstDays(int numberOfDays) { - throw new UnsupportedOperationException("Please implement the BirdWatcher.getCountForFirstDays() method"); + // throw new UnsupportedOperationException("Please implement the BirdWatcher.getCountForFirstDays() method"); + int getTotalCount=0; + if(numberOfDays>birdsPerDay.length){ + numberOfDays = birdsPerDay.length; + } + for(int i=0;i= 5) { + busyDays++; + } + } + return busyDays; } -} +} \ No newline at end of file From f2fc70d6f3fb7fbd5c2876df3b21dbab2da6f6aa Mon Sep 17 00:00:00 2001 From: Navneet Anand <1629076@kiit.ac.in> Date: Sat, 13 Dec 2025 13:09:37 +0530 Subject: [PATCH 3/4] Solution for the Squeaky Clean Problem on Exercism. In this exercise you will implement a partial set of utility routines to help a developer clean up SqueakyClean names. In the 4 tasks you will gradually build up the clean method. A valid SqueakyClean name is comprised of zero or more letters and underscores. In all cases the input string is guaranteed to be non-null. Note that the clean method should treat an empty string as valid. --- .../src/main/java/SqueakyClean.java | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/exercises/concept/squeaky-clean/src/main/java/SqueakyClean.java b/exercises/concept/squeaky-clean/src/main/java/SqueakyClean.java index c56787fab..4063dfd90 100644 --- a/exercises/concept/squeaky-clean/src/main/java/SqueakyClean.java +++ b/exercises/concept/squeaky-clean/src/main/java/SqueakyClean.java @@ -1,5 +1,35 @@ class SqueakyClean { static String clean(String identifier) { - throw new UnsupportedOperationException("Please implement the (static) SqueakyClean.clean() method"); + // throw new UnsupportedOperationException("Please implement the (static) SqueakyClean.clean() method"); + int index =0; + String cleanString = identifier.replace(' ','_'); + if(cleanString.contains("-")) { + index = cleanString.indexOf('-'); + cleanString = cleanString.replace("-", ""); + cleanString = cleanString.substring(0,index) + cleanString.substring(index,index+1).toUpperCase() + cleanString.substring(index+1); + } + char[] chars = cleanString.toCharArray(); + String newString = ""; + for(char c : chars) { + if(c=='4') c = 'a'; + else if(c=='3') c = 'e'; + else if(c=='0') c = 'o'; + else if(c=='1') c = 'l'; + else if(c=='7') c = 't'; + + newString += c; + } + cleanString = newString; + + chars = cleanString.toCharArray(); + newString = ""; + for(char c : chars) { + if(Character.isAlphabetic(c)) newString += c; + else if(c=='_') newString += c; + } + cleanString = newString; + + + return cleanString; } } From 9fa497bd21785671dd17cadcfeb02127074fbc6b Mon Sep 17 00:00:00 2001 From: Navneet Anand <1629076@kiit.ac.in> Date: Sat, 13 Dec 2025 13:17:59 +0530 Subject: [PATCH 4/4] Solution for the Squeaky Clean Problem on Exercism. In this exercise you will implement a partial set of utility routines to help a developer clean up SqueakyClean names. In the 4 tasks you will gradually build up the clean method. A valid SqueakyClean name is comprised of zero or more letters and underscores. In all cases the input string is guaranteed to be non-null. Note that the clean method should treat an empty string as valid. --- exercises/concept/squeaky-clean/src/main/java/SqueakyClean.java | 1 - 1 file changed, 1 deletion(-) diff --git a/exercises/concept/squeaky-clean/src/main/java/SqueakyClean.java b/exercises/concept/squeaky-clean/src/main/java/SqueakyClean.java index 4063dfd90..2a8d51751 100644 --- a/exercises/concept/squeaky-clean/src/main/java/SqueakyClean.java +++ b/exercises/concept/squeaky-clean/src/main/java/SqueakyClean.java @@ -29,7 +29,6 @@ static String clean(String identifier) { } cleanString = newString; - return cleanString; } }