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/7] 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/7] 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/7] 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/7] 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; } } From 756235fa58b94f1f64ba2c9e9586a42870b66704 Mon Sep 17 00:00:00 2001 From: Navneet Anand <1629076@kiit.ac.in> Date: Mon, 15 Dec 2025 17:37:19 +0530 Subject: [PATCH 5/7] Solution for the Jedlik's Toy Car Problem on Exercism. Instructions: In this exercise you'll be playing around with a remote controlled car, which you've finally saved enough money for to buy. Cars start with full (100%) batteries. Each time you drive the car using the remote control, it covers 20 meters and drains one percent of the battery. The remote controlled car has a fancy LED display that shows two bits of information: The total distance it has driven, displayed as: "Driven meters". The remaining battery charge, displayed as: "Battery at %". If the battery is at 0%, you can't drive the car anymore and the battery display will show "Battery empty". You have six tasks, each of which will work with remote controlled car instances. --- .../src/main/java/JedliksToyCar.java | 35 ++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/exercises/concept/jedliks-toy-car/src/main/java/JedliksToyCar.java b/exercises/concept/jedliks-toy-car/src/main/java/JedliksToyCar.java index d9906a7b8..0e17182a6 100644 --- a/exercises/concept/jedliks-toy-car/src/main/java/JedliksToyCar.java +++ b/exercises/concept/jedliks-toy-car/src/main/java/JedliksToyCar.java @@ -1,17 +1,44 @@ public class JedliksToyCar { + private int distance=0; + private int battery=100; + public static JedliksToyCar buy() { - throw new UnsupportedOperationException("Please implement the (static) JedliksToyCar.buy() method"); + // throw new UnsupportedOperationException("Please implement the (static) JedliksToyCar.buy() method"); + JedliksToyCar car = new JedliksToyCar(); + return car; } public String distanceDisplay() { - throw new UnsupportedOperationException("Please implement the JedliksToyCar.distanceDisplay() method"); + // throw new UnsupportedOperationException("Please implement the JedliksToyCar.distanceDisplay() method"); + + + String carDistanceDisplay = null; + if (this.distance <= 2000) { + carDistanceDisplay = "Driven " + this.distance + " meters"; + } + else if(this.distance > 2000) { + carDistanceDisplay = "Driven 2000 meters"; + } + + return carDistanceDisplay; } public String batteryDisplay() { - throw new UnsupportedOperationException("Please implement the JedliksToyCar.batteryDisplay() method"); + // throw new UnsupportedOperationException("Please implement the JedliksToyCar.batteryDisplay() method"); + String carBatteryDisplay = null; + if (this.battery <= 100 && this.battery >= 1) { + carBatteryDisplay = "Battery at "+ this.battery +"%"; + } + else if(this.battery <= 0) { + carBatteryDisplay = "Battery empty"; + } + return carBatteryDisplay; } public void drive() { - throw new UnsupportedOperationException("Please implement the JedliksToyCar.drive() method"); + // throw new UnsupportedOperationException("Please implement the JedliksToyCar.drive() method"); + this.distance += 20; + this.battery -= 1; + } } From c919dab5d7a832e2386e8d114bc81e134f7e30fc Mon Sep 17 00:00:00 2001 From: Navneet Anand <1629076@kiit.ac.in> Date: Tue, 16 Dec 2025 21:39:14 +0530 Subject: [PATCH 6/7] Solution for the Booking up for a Beauty Problem on Exercism. Instructions: In this exercise you'll be working on an appointment scheduler for a beauty salon in New York that opened on September 15th in 2012. --- .../src/main/java/AppointmentScheduler.java | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/exercises/concept/booking-up-for-beauty/src/main/java/AppointmentScheduler.java b/exercises/concept/booking-up-for-beauty/src/main/java/AppointmentScheduler.java index e60072f9e..e9fa07023 100644 --- a/exercises/concept/booking-up-for-beauty/src/main/java/AppointmentScheduler.java +++ b/exercises/concept/booking-up-for-beauty/src/main/java/AppointmentScheduler.java @@ -1,24 +1,36 @@ import java.time.LocalDate; import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; class AppointmentScheduler { public LocalDateTime schedule(String appointmentDateDescription) { - throw new UnsupportedOperationException("Please implement the AppointmentScheduler.schedule() method"); + // throw new UnsupportedOperationException("Please implement the AppointmentScheduler.schedule() method"); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy HH:mm:ss"); + LocalDateTime date = LocalDateTime.parse(appointmentDateDescription, formatter); + + DateTimeFormatter printer = DateTimeFormatter.ofPattern("yyyy, MM, dd, HH, mm, ss"); + printer.format(date); + return LocalDateTime.of(date.getYear(), date.getMonth(), date.getDayOfMonth(), date.getHour(), date.getMinute(), date.getSecond()); } public boolean hasPassed(LocalDateTime appointmentDate) { - throw new UnsupportedOperationException("Please implement the AppointmentScheduler.hasPassed() method"); + // throw new UnsupportedOperationException("Please implement the AppointmentScheduler.hasPassed() method"); + return appointmentDate.isBefore(LocalDateTime.now()); } public boolean isAfternoonAppointment(LocalDateTime appointmentDate) { - throw new UnsupportedOperationException("Please implement the AppointmentScheduler.isAfternoonAppointment() method"); + // throw new UnsupportedOperationException("Please implement the AppointmentScheduler.isAfternoonAppointment() method"); + return appointmentDate.getHour() >= 12 && appointmentDate.getHour() < 18; } public String getDescription(LocalDateTime appointmentDate) { - throw new UnsupportedOperationException("Please implement the AppointmentScheduler.getDescription() method"); + // throw new UnsupportedOperationException("Please implement the AppointmentScheduler.getDescription() method"); + DateTimeFormatter printer = DateTimeFormatter.ofPattern("EEEE, MMMM d, yyyy, 'at' h:mm a'.'"); + return "You have an appointment on "+printer.format(appointmentDate); } public LocalDate getAnniversaryDate() { - throw new UnsupportedOperationException("Please implement the AppointmentScheduler.getAnniversaryDate() method"); + // throw new UnsupportedOperationException("Please implement the AppointmentScheduler.getAnniversaryDate() method"); + return LocalDate.of(LocalDate.now().getYear(), 9,15); } } From 004b7f85b3faa299eb5ac5c429d986d42d72068c Mon Sep 17 00:00:00 2001 From: Navneet Anand <1629076@kiit.ac.in> Date: Wed, 17 Dec 2025 13:44:38 +0530 Subject: [PATCH 7/7] Solution for the Karl's Languages Problem on Exercism. Instructions: Karl wants to keep track of a list of languages to learn on Exercism's website. Karl needs to be able to add new languages, remove old ones and check if certain languages are in the list. It would be very exciting if Karl wants to learn Java or Kotlin! --- .../src/main/java/LanguageList.java | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/exercises/concept/karls-languages/src/main/java/LanguageList.java b/exercises/concept/karls-languages/src/main/java/LanguageList.java index 0da6b44c7..5cb188f60 100644 --- a/exercises/concept/karls-languages/src/main/java/LanguageList.java +++ b/exercises/concept/karls-languages/src/main/java/LanguageList.java @@ -5,30 +5,37 @@ public class LanguageList { private final List languages = new ArrayList<>(); public boolean isEmpty() { - throw new UnsupportedOperationException("Please implement the isEmpty() method"); + //throw new UnsupportedOperationException("Please implement the isEmpty() method"); + return languages.isEmpty(); } public void addLanguage(String language) { - throw new UnsupportedOperationException("Please implement the addLanguage() method"); + // throw new UnsupportedOperationException("Please implement the addLanguage() method"); + languages.add(language); } public void removeLanguage(String language) { - throw new UnsupportedOperationException("Please implement the removeLanguage() method"); + // throw new UnsupportedOperationException("Please implement the removeLanguage() method"); + languages.remove(language); } public String firstLanguage() { - throw new UnsupportedOperationException("Please implement the firstLanguage() method"); + // throw new UnsupportedOperationException("Please implement the firstLanguage() method"); + return languages.getFirst(); } public int count() { - throw new UnsupportedOperationException("Please implement the count() method"); + // throw new UnsupportedOperationException("Please implement the count() method"); + return languages.size(); } public boolean containsLanguage(String language) { - throw new UnsupportedOperationException("Please implement the containsLanguage() method"); + // throw new UnsupportedOperationException("Please implement the containsLanguage() method"); + return languages.contains(language); } public boolean isExciting() { - throw new UnsupportedOperationException("Please implement the isExciting() method"); + // throw new UnsupportedOperationException("Please implement the isExciting() method"); + return languages.contains("Java") || languages.contains("Kotlin"); } }