diff --git a/Ahmad/puzzles/.gitignore b/Ahmad/2_puzzles/.gitignore similarity index 100% rename from Ahmad/puzzles/.gitignore rename to Ahmad/2_puzzles/.gitignore diff --git a/Ahmad/2_puzzles/.project b/Ahmad/2_puzzles/.project new file mode 100644 index 0000000..84e37cf --- /dev/null +++ b/Ahmad/2_puzzles/.project @@ -0,0 +1,11 @@ + + + puzzles_2 + + + + + + + + diff --git a/Ahmad/puzzles/assignment_04/.classpath b/Ahmad/2_puzzles/assignment_01/.classpath similarity index 95% rename from Ahmad/puzzles/assignment_04/.classpath rename to Ahmad/2_puzzles/assignment_01/.classpath index 6ee61f2..57bca72 100644 --- a/Ahmad/puzzles/assignment_04/.classpath +++ b/Ahmad/2_puzzles/assignment_01/.classpath @@ -1,6 +1,6 @@ - + diff --git a/Ahmad/puzzles/prereq-practice/.gitignore b/Ahmad/2_puzzles/assignment_01/.gitignore similarity index 100% rename from Ahmad/puzzles/prereq-practice/.gitignore rename to Ahmad/2_puzzles/assignment_01/.gitignore diff --git a/Ahmad/puzzles/assignment_01/.project b/Ahmad/2_puzzles/assignment_01/.project similarity index 100% rename from Ahmad/puzzles/assignment_01/.project rename to Ahmad/2_puzzles/assignment_01/.project diff --git a/Ahmad/puzzles/prereq-practice/.settings/org.eclipse.m2e.core.prefs b/Ahmad/2_puzzles/assignment_01/.settings/org.eclipse.m2e.core.prefs similarity index 100% rename from Ahmad/puzzles/prereq-practice/.settings/org.eclipse.m2e.core.prefs rename to Ahmad/2_puzzles/assignment_01/.settings/org.eclipse.m2e.core.prefs diff --git a/Ahmad/puzzles/prereq-practice/pom.xml b/Ahmad/2_puzzles/assignment_01/pom.xml similarity index 100% rename from Ahmad/puzzles/prereq-practice/pom.xml rename to Ahmad/2_puzzles/assignment_01/pom.xml diff --git a/Ahmad/puzzles/prereq-practice/src/beanScope-applicationContext.xml b/Ahmad/2_puzzles/assignment_01/src/beanScope-applicationContext.xml similarity index 100% rename from Ahmad/puzzles/prereq-practice/src/beanScope-applicationContext.xml rename to Ahmad/2_puzzles/assignment_01/src/beanScope-applicationContext.xml diff --git a/Ahmad/puzzles/prereq-practice/src/com/luv2code/springdemo/BeanScopeDemoApp.java b/Ahmad/2_puzzles/assignment_01/src/com/luv2code/springdemo/BeanScopeDemoApp.java similarity index 100% rename from Ahmad/puzzles/prereq-practice/src/com/luv2code/springdemo/BeanScopeDemoApp.java rename to Ahmad/2_puzzles/assignment_01/src/com/luv2code/springdemo/BeanScopeDemoApp.java diff --git a/Ahmad/puzzles/prereq-practice/src/com/luv2code/springdemo/RandomFortuneService.java b/Ahmad/2_puzzles/assignment_01/src/com/luv2code/springdemo/RandomFortuneService.java similarity index 100% rename from Ahmad/puzzles/prereq-practice/src/com/luv2code/springdemo/RandomFortuneService.java rename to Ahmad/2_puzzles/assignment_01/src/com/luv2code/springdemo/RandomFortuneService.java diff --git a/Ahmad/puzzles/assignment_02/.classpath b/Ahmad/2_puzzles/assignment_02/.classpath similarity index 95% rename from Ahmad/puzzles/assignment_02/.classpath rename to Ahmad/2_puzzles/assignment_02/.classpath index 6ee61f2..57bca72 100644 --- a/Ahmad/puzzles/assignment_02/.classpath +++ b/Ahmad/2_puzzles/assignment_02/.classpath @@ -1,6 +1,6 @@ - + diff --git a/Ahmad/puzzles/assignment_01/.gitignore b/Ahmad/2_puzzles/assignment_02/.gitignore similarity index 100% rename from Ahmad/puzzles/assignment_01/.gitignore rename to Ahmad/2_puzzles/assignment_02/.gitignore diff --git a/Ahmad/puzzles/assignment_02/.project b/Ahmad/2_puzzles/assignment_02/.project similarity index 100% rename from Ahmad/puzzles/assignment_02/.project rename to Ahmad/2_puzzles/assignment_02/.project diff --git a/Ahmad/2_puzzles/assignment_02/.settings/org.eclipse.core.resources.prefs b/Ahmad/2_puzzles/assignment_02/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_02/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/Ahmad/puzzles/assignment_04/.settings/org.eclipse.jdt.core.prefs b/Ahmad/2_puzzles/assignment_02/.settings/org.eclipse.jdt.core.prefs similarity index 63% rename from Ahmad/puzzles/assignment_04/.settings/org.eclipse.jdt.core.prefs rename to Ahmad/2_puzzles/assignment_02/.settings/org.eclipse.jdt.core.prefs index 021167a..8c9943d 100644 --- a/Ahmad/puzzles/assignment_04/.settings/org.eclipse.jdt.core.prefs +++ b/Ahmad/2_puzzles/assignment_02/.settings/org.eclipse.jdt.core.prefs @@ -1,12 +1,14 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=9 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=9 +org.eclipse.jdt.core.compiler.compliance=17 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning org.eclipse.jdt.core.compiler.release=enabled -org.eclipse.jdt.core.compiler.source=9 +org.eclipse.jdt.core.compiler.source=17 diff --git a/Ahmad/puzzles/assignment_02/src/assignment_02/App.java b/Ahmad/2_puzzles/assignment_02/src/assignment_02/App.java similarity index 66% rename from Ahmad/puzzles/assignment_02/src/assignment_02/App.java rename to Ahmad/2_puzzles/assignment_02/src/assignment_02/App.java index e786618..13acb2b 100644 --- a/Ahmad/puzzles/assignment_02/src/assignment_02/App.java +++ b/Ahmad/2_puzzles/assignment_02/src/assignment_02/App.java @@ -21,33 +21,22 @@ public class App { */ public static int speedingFine(int speed, boolean isHoliday) { -// if (isHoliday && (speed > 65 && speed < 86 )) { -// return 100; -// } else if (!isHoliday && (speed > 59 && speed < 81 )) { -// return 100; -// } else if (isHoliday && (speed > 85)) { -// return 200; -// } else if (!isHoliday && (speed > 80)) { -// return 200; -// } else { -// return 0; -// } - int minSpeed = 60; - int maxSpeed = 80; + int min = 60; + int max = 80; int fine = 0; - if(isHoliday) { - minSpeed += 5; - maxSpeed += 5; + if (isHoliday == true) { + min += 5; + max += 5; } - if(speed >= maxSpeed) + if (speed > max){ fine = 200; - if(speed <= minSpeed) - fine = 0; - if(speed > minSpeed && speed <= maxSpeed) + } + if(speed > min && speed <= max) { fine = 100; + } return fine; } diff --git a/Ahmad/puzzles/assignment_02/src/ignore/TestingUtils.java b/Ahmad/2_puzzles/assignment_02/src/ignore/TestingUtils.java similarity index 100% rename from Ahmad/puzzles/assignment_02/src/ignore/TestingUtils.java rename to Ahmad/2_puzzles/assignment_02/src/ignore/TestingUtils.java diff --git a/Ahmad/puzzles/assignment_05/.classpath b/Ahmad/2_puzzles/assignment_03/.classpath similarity index 95% rename from Ahmad/puzzles/assignment_05/.classpath rename to Ahmad/2_puzzles/assignment_03/.classpath index 6ee61f2..57bca72 100644 --- a/Ahmad/puzzles/assignment_05/.classpath +++ b/Ahmad/2_puzzles/assignment_03/.classpath @@ -1,6 +1,6 @@ - + diff --git a/Ahmad/puzzles/assignment_02/.gitignore b/Ahmad/2_puzzles/assignment_03/.gitignore similarity index 100% rename from Ahmad/puzzles/assignment_02/.gitignore rename to Ahmad/2_puzzles/assignment_03/.gitignore diff --git a/Ahmad/puzzles/assignment_03/.project b/Ahmad/2_puzzles/assignment_03/.project similarity index 100% rename from Ahmad/puzzles/assignment_03/.project rename to Ahmad/2_puzzles/assignment_03/.project diff --git a/Ahmad/2_puzzles/assignment_03/.settings/org.eclipse.core.resources.prefs b/Ahmad/2_puzzles/assignment_03/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_03/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/Ahmad/puzzles/assignment_05/.settings/org.eclipse.jdt.core.prefs b/Ahmad/2_puzzles/assignment_03/.settings/org.eclipse.jdt.core.prefs similarity index 63% rename from Ahmad/puzzles/assignment_05/.settings/org.eclipse.jdt.core.prefs rename to Ahmad/2_puzzles/assignment_03/.settings/org.eclipse.jdt.core.prefs index 021167a..8c9943d 100644 --- a/Ahmad/puzzles/assignment_05/.settings/org.eclipse.jdt.core.prefs +++ b/Ahmad/2_puzzles/assignment_03/.settings/org.eclipse.jdt.core.prefs @@ -1,12 +1,14 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=9 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=9 +org.eclipse.jdt.core.compiler.compliance=17 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning org.eclipse.jdt.core.compiler.release=enabled -org.eclipse.jdt.core.compiler.source=9 +org.eclipse.jdt.core.compiler.source=17 diff --git a/Ahmad/puzzles/assignment_03/src/assignment_03/App.java b/Ahmad/2_puzzles/assignment_03/src/assignment_03/App.java similarity index 79% rename from Ahmad/puzzles/assignment_03/src/assignment_03/App.java rename to Ahmad/2_puzzles/assignment_03/src/assignment_03/App.java index df96123..c595390 100644 --- a/Ahmad/puzzles/assignment_03/src/assignment_03/App.java +++ b/Ahmad/2_puzzles/assignment_03/src/assignment_03/App.java @@ -16,12 +16,9 @@ public class App { twoSumOne(3, 2, 2) ---> false
*/ public static boolean twoSumOne(int a, int b, int c) { -// if((a + b == c) || (a + c == b) || (b + c == a)) { -// return true; -// } else { -// return false; -// } - return (a + b == c) || (a + c == b) || (b + c == a); + + return (a + b == c) || (b + c == a) || (a + c == b); + } diff --git a/Ahmad/puzzles/assignment_03/src/ignore/TestingUtils.java b/Ahmad/2_puzzles/assignment_03/src/ignore/TestingUtils.java similarity index 100% rename from Ahmad/puzzles/assignment_03/src/ignore/TestingUtils.java rename to Ahmad/2_puzzles/assignment_03/src/ignore/TestingUtils.java diff --git a/Ahmad/puzzles/assignment_03/.classpath b/Ahmad/2_puzzles/assignment_04/.classpath similarity index 95% rename from Ahmad/puzzles/assignment_03/.classpath rename to Ahmad/2_puzzles/assignment_04/.classpath index 6ee61f2..57bca72 100644 --- a/Ahmad/puzzles/assignment_03/.classpath +++ b/Ahmad/2_puzzles/assignment_04/.classpath @@ -1,6 +1,6 @@ - + diff --git a/Ahmad/puzzles/assignment_03/.gitignore b/Ahmad/2_puzzles/assignment_04/.gitignore similarity index 100% rename from Ahmad/puzzles/assignment_03/.gitignore rename to Ahmad/2_puzzles/assignment_04/.gitignore diff --git a/Ahmad/puzzles/assignment_04/.project b/Ahmad/2_puzzles/assignment_04/.project similarity index 100% rename from Ahmad/puzzles/assignment_04/.project rename to Ahmad/2_puzzles/assignment_04/.project diff --git a/Ahmad/2_puzzles/assignment_04/.settings/org.eclipse.core.resources.prefs b/Ahmad/2_puzzles/assignment_04/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_04/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/Ahmad/puzzles/assignment_02/.settings/org.eclipse.jdt.core.prefs b/Ahmad/2_puzzles/assignment_04/.settings/org.eclipse.jdt.core.prefs similarity index 63% rename from Ahmad/puzzles/assignment_02/.settings/org.eclipse.jdt.core.prefs rename to Ahmad/2_puzzles/assignment_04/.settings/org.eclipse.jdt.core.prefs index 021167a..8c9943d 100644 --- a/Ahmad/puzzles/assignment_02/.settings/org.eclipse.jdt.core.prefs +++ b/Ahmad/2_puzzles/assignment_04/.settings/org.eclipse.jdt.core.prefs @@ -1,12 +1,14 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=9 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=9 +org.eclipse.jdt.core.compiler.compliance=17 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning org.eclipse.jdt.core.compiler.release=enabled -org.eclipse.jdt.core.compiler.source=9 +org.eclipse.jdt.core.compiler.source=17 diff --git a/Ahmad/puzzles/assignment_04/src/assignment_04/App.java b/Ahmad/2_puzzles/assignment_04/src/assignment_04/App.java similarity index 83% rename from Ahmad/puzzles/assignment_04/src/assignment_04/App.java rename to Ahmad/2_puzzles/assignment_04/src/assignment_04/App.java index ef8b800..1ba3c70 100644 --- a/Ahmad/puzzles/assignment_04/src/assignment_04/App.java +++ b/Ahmad/2_puzzles/assignment_04/src/assignment_04/App.java @@ -19,15 +19,20 @@ public class App { */ public static boolean birdsSinging(int temp, boolean isSummer) { - int maxTemp = 91; - int minTemp = 59; + int min = 60; + int max = 90; + boolean singing = false; - if(isSummer) { - maxTemp = 101; + if (isSummer) { + max += 10; + } + + if (temp >= min && temp <= max) { + singing = true; } - return (temp < maxTemp) && (temp > minTemp); + return singing; } diff --git a/Ahmad/puzzles/assignment_04/src/ignore/TestingUtils.java b/Ahmad/2_puzzles/assignment_04/src/ignore/TestingUtils.java similarity index 100% rename from Ahmad/puzzles/assignment_04/src/ignore/TestingUtils.java rename to Ahmad/2_puzzles/assignment_04/src/ignore/TestingUtils.java diff --git a/Ahmad/2_puzzles/assignment_05/.classpath b/Ahmad/2_puzzles/assignment_05/.classpath new file mode 100644 index 0000000..57bca72 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_05/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Ahmad/puzzles/assignment_04/.gitignore b/Ahmad/2_puzzles/assignment_05/.gitignore similarity index 100% rename from Ahmad/puzzles/assignment_04/.gitignore rename to Ahmad/2_puzzles/assignment_05/.gitignore diff --git a/Ahmad/puzzles/assignment_05/.project b/Ahmad/2_puzzles/assignment_05/.project similarity index 100% rename from Ahmad/puzzles/assignment_05/.project rename to Ahmad/2_puzzles/assignment_05/.project diff --git a/Ahmad/2_puzzles/assignment_05/.settings/org.eclipse.core.resources.prefs b/Ahmad/2_puzzles/assignment_05/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_05/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/Ahmad/puzzles/assignment_03/.settings/org.eclipse.jdt.core.prefs b/Ahmad/2_puzzles/assignment_05/.settings/org.eclipse.jdt.core.prefs similarity index 63% rename from Ahmad/puzzles/assignment_03/.settings/org.eclipse.jdt.core.prefs rename to Ahmad/2_puzzles/assignment_05/.settings/org.eclipse.jdt.core.prefs index 021167a..8c9943d 100644 --- a/Ahmad/puzzles/assignment_03/.settings/org.eclipse.jdt.core.prefs +++ b/Ahmad/2_puzzles/assignment_05/.settings/org.eclipse.jdt.core.prefs @@ -1,12 +1,14 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=9 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=9 +org.eclipse.jdt.core.compiler.compliance=17 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning org.eclipse.jdt.core.compiler.release=enabled -org.eclipse.jdt.core.compiler.source=9 +org.eclipse.jdt.core.compiler.source=17 diff --git a/Ahmad/puzzles/assignment_05/src/assignment_05/App.java b/Ahmad/2_puzzles/assignment_05/src/assignment_05/App.java similarity index 58% rename from Ahmad/puzzles/assignment_05/src/assignment_05/App.java rename to Ahmad/2_puzzles/assignment_05/src/assignment_05/App.java index 7634398..361f3b3 100644 --- a/Ahmad/puzzles/assignment_05/src/assignment_05/App.java +++ b/Ahmad/2_puzzles/assignment_05/src/assignment_05/App.java @@ -5,8 +5,10 @@ public class App { /** - Given three ints, first, second, third, return true if second is greater than first, and third is - greater than second. However, with the exception that if the parameter "itsOk" is true, + Given three ints, first, second, third, + return true if second is greater than first, and third is greater than second. + + However, with the exception that if the parameter "itsOk" is true, second does not need to be greater than first but still better be less than third.

@@ -18,18 +20,19 @@ public class App { */ public static boolean isOrdered(int first, int second, int third, boolean itsOk) { - boolean greaterThanSecond = false; - boolean greaterThanFirst = false; + boolean value = (itsOk) ? (second < third) : (second > first && third > second); - if (third > second) { - greaterThanSecond = true; - } +// boolean ordered = false; +// +// if(!itsOk && second > first && third > second) { +// ordered = true; +// } +// if(itsOk && second < third) { +// ordered = true; +// } - if (second > first) { - greaterThanFirst = true; - } - return (itsOk && greaterThanSecond) || (greaterThanSecond && greaterThanFirst); + return value; } diff --git a/Ahmad/puzzles/assignment_05/src/ignore/TestingUtils.java b/Ahmad/2_puzzles/assignment_05/src/ignore/TestingUtils.java similarity index 100% rename from Ahmad/puzzles/assignment_05/src/ignore/TestingUtils.java rename to Ahmad/2_puzzles/assignment_05/src/ignore/TestingUtils.java diff --git a/Ahmad/2_puzzles/assignment_06/.classpath b/Ahmad/2_puzzles/assignment_06/.classpath new file mode 100644 index 0000000..57bca72 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_06/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Ahmad/puzzles/assignment_05/.gitignore b/Ahmad/2_puzzles/assignment_06/.gitignore similarity index 100% rename from Ahmad/puzzles/assignment_05/.gitignore rename to Ahmad/2_puzzles/assignment_06/.gitignore diff --git a/Ahmad/puzzles/assignment_06/.project b/Ahmad/2_puzzles/assignment_06/.project similarity index 100% rename from Ahmad/puzzles/assignment_06/.project rename to Ahmad/2_puzzles/assignment_06/.project diff --git a/Ahmad/2_puzzles/assignment_06/.settings/org.eclipse.core.resources.prefs b/Ahmad/2_puzzles/assignment_06/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_06/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/Ahmad/2_puzzles/assignment_06/.settings/org.eclipse.jdt.core.prefs b/Ahmad/2_puzzles/assignment_06/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..8c9943d --- /dev/null +++ b/Ahmad/2_puzzles/assignment_06/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/Ahmad/puzzles/assignment_06/src/assignment_06/App.java b/Ahmad/2_puzzles/assignment_06/src/assignment_06/App.java similarity index 87% rename from Ahmad/puzzles/assignment_06/src/assignment_06/App.java rename to Ahmad/2_puzzles/assignment_06/src/assignment_06/App.java index 44b1733..5ab7e6d 100644 --- a/Ahmad/puzzles/assignment_06/src/assignment_06/App.java +++ b/Ahmad/2_puzzles/assignment_06/src/assignment_06/App.java @@ -18,7 +18,13 @@ public class App { */ public static boolean isCool(int n) { - return (n % 11 == 0) || (n % 11 == 1); + boolean cool = false; + + if(n % 11 == 0 || n % 11 == 1) { + cool = true; + } + + return cool; } diff --git a/Ahmad/puzzles/assignment_06/src/ignore/TestingUtils.java b/Ahmad/2_puzzles/assignment_06/src/ignore/TestingUtils.java similarity index 100% rename from Ahmad/puzzles/assignment_06/src/ignore/TestingUtils.java rename to Ahmad/2_puzzles/assignment_06/src/ignore/TestingUtils.java diff --git a/Ahmad/2_puzzles/assignment_07/.classpath b/Ahmad/2_puzzles/assignment_07/.classpath new file mode 100644 index 0000000..57bca72 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_07/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Ahmad/puzzles/assignment_06/.gitignore b/Ahmad/2_puzzles/assignment_07/.gitignore similarity index 100% rename from Ahmad/puzzles/assignment_06/.gitignore rename to Ahmad/2_puzzles/assignment_07/.gitignore diff --git a/Ahmad/puzzles/assignment_07/.project b/Ahmad/2_puzzles/assignment_07/.project similarity index 100% rename from Ahmad/puzzles/assignment_07/.project rename to Ahmad/2_puzzles/assignment_07/.project diff --git a/Ahmad/2_puzzles/assignment_07/.settings/org.eclipse.core.resources.prefs b/Ahmad/2_puzzles/assignment_07/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_07/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/Ahmad/2_puzzles/assignment_07/.settings/org.eclipse.jdt.core.prefs b/Ahmad/2_puzzles/assignment_07/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..8c9943d --- /dev/null +++ b/Ahmad/2_puzzles/assignment_07/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/Ahmad/puzzles/assignment_07/src/assignment_07/App.java b/Ahmad/2_puzzles/assignment_07/src/assignment_07/App.java similarity index 72% rename from Ahmad/puzzles/assignment_07/src/assignment_07/App.java rename to Ahmad/2_puzzles/assignment_07/src/assignment_07/App.java index 5f4d3ba..d76c8fa 100644 --- a/Ahmad/puzzles/assignment_07/src/assignment_07/App.java +++ b/Ahmad/2_puzzles/assignment_07/src/assignment_07/App.java @@ -21,25 +21,16 @@ public class App { fizzyWizzy(3) ---> "Fizz!"
*/ public static String fizzyWizzy(int n) { - -// if (n % 15 == 0) { -// return "FizzBuzz!"; -// } else if (n % 5 == 0) { -// return "Buzz!"; -// } else if (n % 3 ==0) { -// return "Fizz!"; -// } else { - - boolean fizz = n % 3 == 0; - boolean buzz = n % 5 == 0; - if (fizz && buzz) return "FizzBuzz!"; - if (fizz) return "Fizz!"; - if (buzz) return "Buzz!"; + boolean fizz = n % 3 == 0; + boolean buzz = n % 5 ==0; - return n + "!"; - } - + if(fizz & buzz) return "FizzBuzz!"; + if(fizz) return "Fizz!"; + if(buzz) return "Buzz!"; + + return n + "!"; + } diff --git a/Ahmad/puzzles/assignment_07/src/ignore/TestingUtils.java b/Ahmad/2_puzzles/assignment_07/src/ignore/TestingUtils.java similarity index 100% rename from Ahmad/puzzles/assignment_07/src/ignore/TestingUtils.java rename to Ahmad/2_puzzles/assignment_07/src/ignore/TestingUtils.java diff --git a/Ahmad/2_puzzles/assignment_08/.classpath b/Ahmad/2_puzzles/assignment_08/.classpath new file mode 100644 index 0000000..57bca72 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_08/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Ahmad/puzzles/assignment_07/.gitignore b/Ahmad/2_puzzles/assignment_08/.gitignore similarity index 100% rename from Ahmad/puzzles/assignment_07/.gitignore rename to Ahmad/2_puzzles/assignment_08/.gitignore diff --git a/Ahmad/puzzles/assignment_08/.project b/Ahmad/2_puzzles/assignment_08/.project similarity index 100% rename from Ahmad/puzzles/assignment_08/.project rename to Ahmad/2_puzzles/assignment_08/.project diff --git a/Ahmad/2_puzzles/assignment_08/.settings/org.eclipse.core.resources.prefs b/Ahmad/2_puzzles/assignment_08/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_08/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/Ahmad/2_puzzles/assignment_08/.settings/org.eclipse.jdt.core.prefs b/Ahmad/2_puzzles/assignment_08/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..8c9943d --- /dev/null +++ b/Ahmad/2_puzzles/assignment_08/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/Ahmad/puzzles/assignment_08/src/assignment_08/App.java b/Ahmad/2_puzzles/assignment_08/src/assignment_08/App.java similarity index 66% rename from Ahmad/puzzles/assignment_08/src/assignment_08/App.java rename to Ahmad/2_puzzles/assignment_08/src/assignment_08/App.java index d5b610d..f923aab 100644 --- a/Ahmad/puzzles/assignment_08/src/assignment_08/App.java +++ b/Ahmad/2_puzzles/assignment_08/src/assignment_08/App.java @@ -21,26 +21,13 @@ public class App { public static int sumUnique(int a, int b, int c) { -// if ( a == b && a == c) { -// return 0; -// } else if (a == b) { -// return c; -// } else if (a == c) { -// return b; -// } else if (b == c) { -// return a; -// } else if (a != b && a != c && b !=c ) { -// return a + b + c; -// } else { -// return 0; -// } - - if (a == b && b ==c) return 0; - if (a == b) return c; - if (a == c) return b; - if (b == c) return a; + if (a == b && b ==c) {return 0;}; + if ( a == b ) {return c;}; + if ( a == c ) {return b;}; + if ( b == c ) {return a;}; return a + b + c; + } diff --git a/Ahmad/puzzles/assignment_08/src/ignore/TestingUtils.java b/Ahmad/2_puzzles/assignment_08/src/ignore/TestingUtils.java similarity index 100% rename from Ahmad/puzzles/assignment_08/src/ignore/TestingUtils.java rename to Ahmad/2_puzzles/assignment_08/src/ignore/TestingUtils.java diff --git a/Ahmad/2_puzzles/assignment_09/.classpath b/Ahmad/2_puzzles/assignment_09/.classpath new file mode 100644 index 0000000..57bca72 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_09/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Ahmad/puzzles/assignment_08/.gitignore b/Ahmad/2_puzzles/assignment_09/.gitignore similarity index 100% rename from Ahmad/puzzles/assignment_08/.gitignore rename to Ahmad/2_puzzles/assignment_09/.gitignore diff --git a/Ahmad/puzzles/assignment_09/.project b/Ahmad/2_puzzles/assignment_09/.project similarity index 100% rename from Ahmad/puzzles/assignment_09/.project rename to Ahmad/2_puzzles/assignment_09/.project diff --git a/Ahmad/2_puzzles/assignment_09/.settings/org.eclipse.core.resources.prefs b/Ahmad/2_puzzles/assignment_09/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_09/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/Ahmad/2_puzzles/assignment_09/.settings/org.eclipse.jdt.core.prefs b/Ahmad/2_puzzles/assignment_09/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..8c9943d --- /dev/null +++ b/Ahmad/2_puzzles/assignment_09/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/Ahmad/puzzles/assignment_09/src/assignment_09/App.java b/Ahmad/2_puzzles/assignment_09/src/assignment_09/App.java similarity index 62% rename from Ahmad/puzzles/assignment_09/src/assignment_09/App.java rename to Ahmad/2_puzzles/assignment_09/src/assignment_09/App.java index 9698c59..2a9b52e 100644 --- a/Ahmad/puzzles/assignment_09/src/assignment_09/App.java +++ b/Ahmad/2_puzzles/assignment_09/src/assignment_09/App.java @@ -21,32 +21,16 @@ public class App { */ public static int nearestTwentyOne(int a, int b) { - -// if ( a <= 21 && b <= 21) { -// if (Math.abs(21-a) > Math.abs(21-b)) { -// return b; -// } else { -// return a; -// } -// } else if (a <= 21 && b > 21) { -// return a; -// } else if (b <= 21 && a > 21) { -// return b; -// } else { -// return 0; -// } - if (a > 21 && b > 21) return 0; // disqualify both - if (a > 21 && b <=21) return b; //dsiqualify a - if (a <=21 && b > 21) return a; //disqualify b - if(a > b) { + if(a > 21 && b > 21) return 0; + if(a > 21 && b <- 21) return b; + if(a <= 21 && b > 21) return a; + + if (a > b) return a; - } else { + else return b; - } - } - diff --git a/Ahmad/puzzles/assignment_09/src/ignore/TestingUtils.java b/Ahmad/2_puzzles/assignment_09/src/ignore/TestingUtils.java similarity index 100% rename from Ahmad/puzzles/assignment_09/src/ignore/TestingUtils.java rename to Ahmad/2_puzzles/assignment_09/src/ignore/TestingUtils.java diff --git a/Ahmad/2_puzzles/assignment_10/.classpath b/Ahmad/2_puzzles/assignment_10/.classpath new file mode 100644 index 0000000..57bca72 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_10/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Ahmad/puzzles/assignment_09/.gitignore b/Ahmad/2_puzzles/assignment_10/.gitignore similarity index 100% rename from Ahmad/puzzles/assignment_09/.gitignore rename to Ahmad/2_puzzles/assignment_10/.gitignore diff --git a/Ahmad/puzzles/assignment_10/.project b/Ahmad/2_puzzles/assignment_10/.project similarity index 100% rename from Ahmad/puzzles/assignment_10/.project rename to Ahmad/2_puzzles/assignment_10/.project diff --git a/Ahmad/2_puzzles/assignment_10/.settings/org.eclipse.core.resources.prefs b/Ahmad/2_puzzles/assignment_10/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_10/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/Ahmad/2_puzzles/assignment_10/.settings/org.eclipse.jdt.core.prefs b/Ahmad/2_puzzles/assignment_10/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..8c9943d --- /dev/null +++ b/Ahmad/2_puzzles/assignment_10/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/Ahmad/puzzles/assignment_10/src/assignment_10/App.java b/Ahmad/2_puzzles/assignment_10/src/assignment_10/App.java similarity index 80% rename from Ahmad/puzzles/assignment_10/src/assignment_10/App.java rename to Ahmad/2_puzzles/assignment_10/src/assignment_10/App.java index 09c9fb6..96df596 100644 --- a/Ahmad/puzzles/assignment_10/src/assignment_10/App.java +++ b/Ahmad/2_puzzles/assignment_10/src/assignment_10/App.java @@ -20,12 +20,20 @@ public class App { */ public static int partialSum(int a, int b, int c) { - -// if (a == 13 && b == 13) {a = 0; b = 0; c = 0;} -// if (a == 13) {a = 0; b = 0; c=0;} -// if (b == 13) {b = 0; c = 0;} -// if (c == 13) {c = 0;} - + +// int sum = 0; +// int[] nums = {a, b, c}; +// +// for (int i = 0; i < nums.length; i++) { +// if (nums[i] == 13) { +// break; +// } +// sum += nums[i]; +// } +// +// +// return sum; + if (a == 13) return 0; if (b == 13) return a; if (c == 13) return a + b; diff --git a/Ahmad/puzzles/assignment_10/src/ignore/TestingUtils.java b/Ahmad/2_puzzles/assignment_10/src/ignore/TestingUtils.java similarity index 100% rename from Ahmad/puzzles/assignment_10/src/ignore/TestingUtils.java rename to Ahmad/2_puzzles/assignment_10/src/ignore/TestingUtils.java diff --git a/Ahmad/2_puzzles/assignment_11/.classpath b/Ahmad/2_puzzles/assignment_11/.classpath new file mode 100644 index 0000000..57bca72 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_11/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Ahmad/puzzles/assignment_10/.gitignore b/Ahmad/2_puzzles/assignment_11/.gitignore similarity index 100% rename from Ahmad/puzzles/assignment_10/.gitignore rename to Ahmad/2_puzzles/assignment_11/.gitignore diff --git a/Ahmad/puzzles/puzzles/.project b/Ahmad/2_puzzles/assignment_11/.project similarity index 92% rename from Ahmad/puzzles/puzzles/.project rename to Ahmad/2_puzzles/assignment_11/.project index 302e9f6..7eb9a73 100644 --- a/Ahmad/puzzles/puzzles/.project +++ b/Ahmad/2_puzzles/assignment_11/.project @@ -1,6 +1,6 @@ - puzzles + assignment_11 diff --git a/Ahmad/2_puzzles/assignment_11/.settings/org.eclipse.core.resources.prefs b/Ahmad/2_puzzles/assignment_11/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_11/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/Ahmad/2_puzzles/assignment_11/.settings/org.eclipse.jdt.core.prefs b/Ahmad/2_puzzles/assignment_11/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..8c9943d --- /dev/null +++ b/Ahmad/2_puzzles/assignment_11/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/Ahmad/2_puzzles/assignment_11/src/assignment_11/App.java b/Ahmad/2_puzzles/assignment_11/src/assignment_11/App.java new file mode 100644 index 0000000..0229858 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_11/src/assignment_11/App.java @@ -0,0 +1,46 @@ +package assignment_11; + +import ignore.TestingUtils; + +public class App { + + + /** + + Given a string, return a string where for every char in the original, append another. +
+
+ + * EXPECTATIONS:
+ repeatChar("The") --->"TThhee"
+ repeatChar("AAbb") ---> "AAAAbbbb"
+ repeatChar("Hi-There") ---> "HHii--TThheerree"
+ */ + + public static String repeatChar(String str) { + String result = ""; + + for(int i =0; i " + result.toString(); + return "PASS: repeatChar("+ params1.toString()+ ") -> " + result.toString(); } private static String printFailResult(Object params1, Object expected, Object result){ String ret = "**********************" + "\n"; - ret += "FAIL: middleThree("+ params1.toString()+ ") -> " + result.toString() + ret += "FAIL: repeatChar("+ params1.toString()+") -> " + result.toString() + " Expected: "+ expected.toString(); ret += "\n" + "**********************"; return ret; diff --git a/Ahmad/2_puzzles/assignment_12/.classpath b/Ahmad/2_puzzles/assignment_12/.classpath new file mode 100644 index 0000000..57bca72 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_12/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Ahmad/puzzles/puzzles/.gitignore b/Ahmad/2_puzzles/assignment_12/.gitignore similarity index 100% rename from Ahmad/puzzles/puzzles/.gitignore rename to Ahmad/2_puzzles/assignment_12/.gitignore diff --git a/Ahmad/puzzles/assignment_01/src/assignment_01/.project b/Ahmad/2_puzzles/assignment_12/.project similarity index 92% rename from Ahmad/puzzles/assignment_01/src/assignment_01/.project rename to Ahmad/2_puzzles/assignment_12/.project index d85502a..c5b011e 100644 --- a/Ahmad/puzzles/assignment_01/src/assignment_01/.project +++ b/Ahmad/2_puzzles/assignment_12/.project @@ -1,6 +1,6 @@ - assignment_01 + assignment_12 diff --git a/Ahmad/2_puzzles/assignment_12/.settings/org.eclipse.core.resources.prefs b/Ahmad/2_puzzles/assignment_12/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_12/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/Ahmad/2_puzzles/assignment_12/.settings/org.eclipse.jdt.core.prefs b/Ahmad/2_puzzles/assignment_12/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..8c9943d --- /dev/null +++ b/Ahmad/2_puzzles/assignment_12/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/Ahmad/2_puzzles/assignment_12/src/assignment_12/App.java b/Ahmad/2_puzzles/assignment_12/src/assignment_12/App.java new file mode 100644 index 0000000..b023a78 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_12/src/assignment_12/App.java @@ -0,0 +1,60 @@ +package assignment_12; + +import ignore.TestingUtils; + +public class App { + + + /** + * + Return a version of the given string, where for every star (*) + in the string the star and the chars immediately to its left and right are gone. + So "ab*cd" yields "ad" and "ab**cd" also yields "ad".
+
+ + * EXPECTATIONS:
+ starKill("cd*zq") --->"cq"
+ starKill("ab**cd") ---> "ad"
+ starKill("wacy*xko") ---> "wacko"
+ */ + + public static String starKill(String str) { + + int len = str.length(); + String result = ""; + + for(int i = 0; i < len; i++) { + + if( i == 0 && str.charAt(i) != '*') { + result += str.charAt(i); + } + + if( i > 0 && str.charAt(i) != '*' && str.charAt(i - 1) != '*' ) { + result += str.charAt(i); + } + + if(i > 0 && str.charAt(i) == '*' && str.charAt(i-1) != '*') + result = result.substring(0, result.length() -1); + } + + return result; + + } + + + + + + + + + + + + + //----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// + public static void main(String args[]){ + TestingUtils.runTests(); + + } +} diff --git a/Ahmad/2_puzzles/assignment_12/src/ignore/TestingUtils.java b/Ahmad/2_puzzles/assignment_12/src/ignore/TestingUtils.java new file mode 100644 index 0000000..44664a1 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_12/src/ignore/TestingUtils.java @@ -0,0 +1,36 @@ +package ignore; + +import assignment_12.App; + +public class TestingUtils { + public static void runTests(){ + + String[] params1 = { "ab*cd", "ab**cd", "sm*eilly", "sm*eil*ly", "sm**eil*ly", "sm***eil*ly", "stringy*", + "*stringy", "*str*in*gy", "abc", "a*bc", "ab", "a*b", "a", "a*", "*a", "*", "" }; + + String[] expected = { "ad", "ad", "silly", "siy", "siy", "siy", "string", "tringy", "ty", "abc", "c", "ab", "", + "a", "", "", "", "" }; + + for(int i=0; i < params1.length; i++){ + String result = App.starKill(params1[i]); + if(result.equals(expected[i])) { + System.out.println(printPassResult(params1[i], expected[i], result)); + } else{ + System.out.println(printFailResult(params1[i], expected[i], result)); + } + } + } + + private static String printPassResult(Object params1, Object expected, Object result){ + return "PASS: starKill("+ params1.toString()+ ") -> " + result.toString(); + } + + + private static String printFailResult(Object params1, Object expected, Object result){ + String ret = "**********************" + "\n"; + ret += "FAIL: starKill("+ params1.toString()+") -> " + result.toString() + + " Expected: "+ expected.toString(); + ret += "\n" + "**********************"; + return ret; + } +} \ No newline at end of file diff --git a/Ahmad/2_puzzles/assignment_13/.classpath b/Ahmad/2_puzzles/assignment_13/.classpath new file mode 100644 index 0000000..57bca72 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_13/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Ahmad/2_puzzles/assignment_13/.gitignore b/Ahmad/2_puzzles/assignment_13/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_13/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/puzzles/prereq-practice/.project b/Ahmad/2_puzzles/assignment_13/.project similarity index 91% rename from Ahmad/puzzles/prereq-practice/.project rename to Ahmad/2_puzzles/assignment_13/.project index e3e0bf3..46bb0f6 100644 --- a/Ahmad/puzzles/prereq-practice/.project +++ b/Ahmad/2_puzzles/assignment_13/.project @@ -1,6 +1,6 @@ - prereq-practice + assignment_13 diff --git a/Ahmad/2_puzzles/assignment_13/.settings/org.eclipse.core.resources.prefs b/Ahmad/2_puzzles/assignment_13/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_13/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/Ahmad/2_puzzles/assignment_13/.settings/org.eclipse.jdt.core.prefs b/Ahmad/2_puzzles/assignment_13/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..8c9943d --- /dev/null +++ b/Ahmad/2_puzzles/assignment_13/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/Ahmad/2_puzzles/assignment_13/src/assignment_13/App.java b/Ahmad/2_puzzles/assignment_13/src/assignment_13/App.java new file mode 100644 index 0000000..5f8dcfd --- /dev/null +++ b/Ahmad/2_puzzles/assignment_13/src/assignment_13/App.java @@ -0,0 +1,47 @@ +package assignment_13; + +import ignore.TestingUtils; + +public class App { + + + /** + * + Given an array of strings, return the count of the number of strings with the given length
+
+ + * EXPECTATIONS:
+ wordsCount({"a", "bb", "b", "ccc"}, 1) ---> 2
+ wordsCount({"a", "bb", "b", "ccc"}, 3) ---> 1
+ wordsCount({"a", "bb", "b", "ccc"}, 4) ---> 0
+ */ + + public static int wordsCount(String[] words, int len) { + + int count = 0; + + for(int i = 0; i < words.length; i++) { + + if (words[i].length() == len) + count += 1; + } + + return count; + } + + + + + + + + + + + + //----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// + public static void main(String args[]){ + TestingUtils.runTests(); + + } +} diff --git a/Ahmad/2_puzzles/assignment_13/src/ignore/TestingUtils.java b/Ahmad/2_puzzles/assignment_13/src/ignore/TestingUtils.java new file mode 100644 index 0000000..b6c1c0b --- /dev/null +++ b/Ahmad/2_puzzles/assignment_13/src/ignore/TestingUtils.java @@ -0,0 +1,41 @@ +package ignore; + +import java.util.Arrays; + +import assignment_13.App; + +public class TestingUtils { + public static void runTests(){ + + String[] [] params1 = { { "a", "bb", "b", "ccc" }, { "a", "bb", "b", "ccc" }, { "a", "bb", "b", "ccc" }, + { "xx", "yyy", "x", "yy", "z" }, { "xx", "yyy", "x", "yy", "z" }, { "xx", "yyy", "x", "yy", "z" } }; + + int [] params2 = {1,3,4,1,2,3}; + + int[] expected = { 2, 1, 0, 2, 2, 1 }; + + for(int i=0; i < params1.length; i++){ + int result = App.wordsCount(params1[i], params2[i]); + if(result == expected[i]) { + System.out.println(printPassResult(params1[i], params2[i], expected[i], result)); + } else{ + System.out.println(printFailResult(params1[i], params2[i], expected[i], result)); + } + } + } + + private static String printPassResult(String[] params1, Object params2, Object expected, Object result){ + String str = ""; + + return "PASS: wordsCount("+Arrays.toString(params1)+", "+ params2+ ") -> " + result.toString(); + } + + + private static String printFailResult(String[] params1, Object params2, Object expected, Object result){ + String ret = "**********************" + "\n"; + ret += "FAIL: wordsCount("+Arrays.toString(params1)+", "+ params2+") -> " + result.toString() + + " Expected: "+ expected.toString(); + ret += "\n" + "**********************"; + return ret; + } +} \ No newline at end of file diff --git a/Ahmad/2_puzzles/assignment_14/.classpath b/Ahmad/2_puzzles/assignment_14/.classpath new file mode 100644 index 0000000..57bca72 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_14/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Ahmad/2_puzzles/assignment_14/.gitignore b/Ahmad/2_puzzles/assignment_14/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_14/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/2_puzzles/assignment_14/.project b/Ahmad/2_puzzles/assignment_14/.project new file mode 100644 index 0000000..15f497d --- /dev/null +++ b/Ahmad/2_puzzles/assignment_14/.project @@ -0,0 +1,17 @@ + + + assignment_14 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Ahmad/2_puzzles/assignment_14/.settings/org.eclipse.core.resources.prefs b/Ahmad/2_puzzles/assignment_14/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_14/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/Ahmad/2_puzzles/assignment_14/.settings/org.eclipse.jdt.core.prefs b/Ahmad/2_puzzles/assignment_14/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..8c9943d --- /dev/null +++ b/Ahmad/2_puzzles/assignment_14/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/Ahmad/2_puzzles/assignment_14/src/assignment_14/App.java b/Ahmad/2_puzzles/assignment_14/src/assignment_14/App.java new file mode 100644 index 0000000..726763c --- /dev/null +++ b/Ahmad/2_puzzles/assignment_14/src/assignment_14/App.java @@ -0,0 +1,56 @@ +package assignment_14; + +import ignore.TestingUtils; + +public class App { + + + /** + * + Given 2 arrays that are the same length containing strings, compare the 1st string in one array + to the 1st string in the other array, the 2nd to the 2nd and so on. + Count the number of times that the 2 strings are non-empty and start with the same char. + The strings may be any length, including 0. +
+
+ + * EXPECTATIONS:
+ matchingChar({"aa", "bb", "cc"}, {"aaa", "xx", "bb"}) ---> 1
+ matchingChar({"aa", "bb", "cc"}, {"aaa", "b", "bb"}) ---> 2
+ matchingChar({"aa", "bb", "cc"}, {"", "", "ccc"}) ---> 1
+ */ + + public static int matchingChar(String[] a, String[] b) { + + int count = 0; + + for (int i = 0; i < a.length; i++) { + String str1 = a[i]; + String str2 = b[i]; + + if(!str1.equals("") && !str2.equals("")) { + if(str1.charAt(0) == str2.charAt(0)) + count++; + } + } + + + return count; + } + + + + + + + + + + + + //----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// + public static void main(String args[]){ + TestingUtils.runTests(); + + } +} diff --git a/Ahmad/2_puzzles/assignment_14/src/ignore/TestingUtils.java b/Ahmad/2_puzzles/assignment_14/src/ignore/TestingUtils.java new file mode 100644 index 0000000..2f452c6 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_14/src/ignore/TestingUtils.java @@ -0,0 +1,45 @@ +package ignore; + +import java.util.Arrays; + +import assignment_14.App; + +public class TestingUtils { + public static void runTests(){ + + String[][] params1 = { { "aa", "bb", "cc" }, { "aa", "bb", "cc" }, { "aa", "bb", "cc" }, { "", "", "ccc" }, + { "", "", "" }, { "aa", "bb", "cc" }, { "aa", "", "ccc" }, { "x", "y", "z" }, { "", "y", "z" }, + { "x", "y", "z" }, { "x", "y", "z" }, { "b", "x", "y", "z" }, { "aaa", "bb", "c" } }; + + String[][] params2 = { { "aaa", "xx", "bb" }, { "aaa", "b", "bb" }, { "", "", "ccc" }, { "aa", "bb", "cc" }, + { "", "bb", "cc" }, { "", "", "" }, { "", "bb", "cc" }, { "y", "z", "x" }, { "", "y", "x" }, + { "xx", "yyy", "zzz" }, { "xx", "yyy", "" }, { "a", "xx", "yyy", "zzz" }, { "aaa", "xx", "bb" } }; + + + int[] expected = { 1, 2, 1, 1, 0, 0, 1, 0, 1, 3, 2, 3, 1 }; + + for(int i=0; i < params1.length; i++){ + int result = App.matchingChar(params1[i], params2[i]); + if(result == expected[i]) { + System.out.println(printPassResult(params1[i], params2[i], expected[i], result)); + } else{ + System.out.println(printFailResult(params1[i], params2[i], expected[i], result)); + } + } + } + + private static String printPassResult(String[] params1, String[] params2, Object expected, Object result){ + String str = ""; + + return "PASS: matchingChar("+Arrays.toString(params1)+", "+ Arrays.toString(params2)+ ") -> " + result.toString(); + } + + + private static String printFailResult(String[] params1, String[] params2, Object expected, Object result){ + String ret = "**********************" + "\n"; + ret += "FAIL: matchingChar("+Arrays.toString(params1)+", "+ Arrays.toString(params2)+") -> " + result.toString() + + " Expected: "+ expected.toString(); + ret += "\n" + "**********************"; + return ret; + } +} \ No newline at end of file diff --git a/Ahmad/2_puzzles/assignment_15/.classpath b/Ahmad/2_puzzles/assignment_15/.classpath new file mode 100644 index 0000000..57bca72 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_15/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Ahmad/2_puzzles/assignment_15/.gitignore b/Ahmad/2_puzzles/assignment_15/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_15/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/2_puzzles/assignment_15/.project b/Ahmad/2_puzzles/assignment_15/.project new file mode 100644 index 0000000..ce2a280 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_15/.project @@ -0,0 +1,17 @@ + + + assignment_15 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Ahmad/2_puzzles/assignment_15/.settings/org.eclipse.core.resources.prefs b/Ahmad/2_puzzles/assignment_15/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_15/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/Ahmad/2_puzzles/assignment_15/.settings/org.eclipse.jdt.core.prefs b/Ahmad/2_puzzles/assignment_15/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..8c9943d --- /dev/null +++ b/Ahmad/2_puzzles/assignment_15/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/Ahmad/2_puzzles/assignment_15/src/assignment_15/App.java b/Ahmad/2_puzzles/assignment_15/src/assignment_15/App.java new file mode 100644 index 0000000..2c58417 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_15/src/assignment_15/App.java @@ -0,0 +1,59 @@ +package assignment_15; + +import ignore.TestingUtils; + +public class App { + + + /** + * + Given a string, return the length of the longest streak of the same chars in the string. + +
+
+ + * EXPECTATIONS:
+ longestStreak("hayyeu") ---> 2
+ longestStreak("XPNzzzddOOOxx") ---> 3
+ longestStreak("") ---> 0
+ */ + + public static int longestStreak(String str) { + + int max = 0; + + + + for (int i = 0; i < str.length(); i++) { + int count = 0; + + for(int j = i; j < str.length(); j++) { + if(str.charAt(i) == str.charAt(j)) + count++; + else + break; + } + if (count > max) + max = count; + } + return max; + + } + + + + + + + + + + + + //----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// + public static void main(String args[]){ + TestingUtils.runTests(); + + } +} + diff --git a/Ahmad/2_puzzles/assignment_15/src/ignore/TestingUtils.java b/Ahmad/2_puzzles/assignment_15/src/ignore/TestingUtils.java new file mode 100644 index 0000000..a6e9675 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_15/src/ignore/TestingUtils.java @@ -0,0 +1,36 @@ +package ignore; + +import assignment_15.App; + +public class TestingUtils { + public static void runTests(){ + + + String[] params1 = { "hoopla", "abbCCCddBBBxx", "", "xyz", "xxyz", "xyzz", "abbbcbbbxbbbx", "XXBBBbbxx", + "XXBBBBbbxx", "XXBBBbbxxXXXX", "XX2222BBBbbXX2222" }; + + int[] expected = { 2, 3, 0, 1, 2, 2, 3, 3, 4, 4, 4 }; + + for(int i=0; i < params1.length; i++){ + int result = App.longestStreak(params1[i]); + if(result == expected[i]) { + System.out.println(printPassResult(params1[i], expected[i], result)); + } else{ + System.out.println(printFailResult(params1[i], expected[i], result)); + } + } + } + + private static String printPassResult(Object params1, Object expected, Object result){ + return "PASS: longestStreak("+ params1.toString()+ ") -> " + result.toString(); + } + + + private static String printFailResult(Object params1, Object expected, Object result){ + String ret = "**********************" + "\n"; + ret += "FAIL: longestStreak("+ params1.toString()+ ") -> " + result.toString() + + " Expected: "+ expected.toString(); + ret += "\n" + "**********************"; + return ret; + } +} \ No newline at end of file diff --git a/Ahmad/2_puzzles/assignment_16/.classpath b/Ahmad/2_puzzles/assignment_16/.classpath new file mode 100644 index 0000000..57bca72 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_16/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Ahmad/2_puzzles/assignment_16/.gitignore b/Ahmad/2_puzzles/assignment_16/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_16/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/2_puzzles/assignment_16/.project b/Ahmad/2_puzzles/assignment_16/.project new file mode 100644 index 0000000..5eff228 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_16/.project @@ -0,0 +1,17 @@ + + + assignment_16 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Ahmad/2_puzzles/assignment_16/.settings/org.eclipse.core.resources.prefs b/Ahmad/2_puzzles/assignment_16/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_16/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/Ahmad/2_puzzles/assignment_16/.settings/org.eclipse.jdt.core.prefs b/Ahmad/2_puzzles/assignment_16/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..8c9943d --- /dev/null +++ b/Ahmad/2_puzzles/assignment_16/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/Ahmad/2_puzzles/assignment_16/src/assignment_16/App.java b/Ahmad/2_puzzles/assignment_16/src/assignment_16/App.java new file mode 100644 index 0000000..481c44a --- /dev/null +++ b/Ahmad/2_puzzles/assignment_16/src/assignment_16/App.java @@ -0,0 +1,60 @@ +package assignment_16; + +import ignore.TestingUtils; + +public class App { + + + /** + * + Given a string, compute recursively (no loops) the number of times + lowercase "yo" appears in the string. +
+
+ + * EXPECTATIONS:
+ yoYo("xhyoxx") ---> 1
+ yoYo("nyonnyon")---> 2
+ yoYo("yo") ---> 1
+ */ + + public static int yoYo(String str) { + +// int count = 0; +// for (int i = 0; i < str.length() -1; i++) { +// if(str.charAt(i) == 'y' && str.charAt(i+1) == 'o') +// count++; +// } +// return count; + + + if(str.length() < 2) + return 0; + + if(str.substring(0, 2).equals("yo")) + return 1 + yoYo(str.substring(1)); + + else + + return yoYo(str.substring(1)); + } + + + + + + + + + + + + + + //----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// + public static void main(String args[]){ + TestingUtils.runTests(); + + } +} + diff --git a/Ahmad/2_puzzles/assignment_16/src/ignore/TestingUtils.java b/Ahmad/2_puzzles/assignment_16/src/ignore/TestingUtils.java new file mode 100644 index 0000000..dcd2da7 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_16/src/ignore/TestingUtils.java @@ -0,0 +1,36 @@ +package ignore; + +import assignment_16.App; + +public class TestingUtils { + public static void runTests(){ + + + String[] params1 = { "xxyoxx", "yyoxyoy", "yo", "yoyoy", "y", "", "oyoyoyoyoy", + "oyoyoyoyoyo", "yoAAyo12yo", "xyoxhxiyohhyoh", "yogurt"}; + + int[] expected = { 1, 2, 1, 2, 0, 0, 4, 5, 3, 3, 1 }; + + for(int i=0; i < params1.length; i++){ + int result = App.yoYo(params1[i]); + if(result == expected[i]) { + System.out.println(printPassResult(params1[i], expected[i], result)); + } else{ + System.out.println(printFailResult(params1[i], expected[i], result)); + } + } + } + + private static String printPassResult(Object params1, Object expected, Object result){ + return "PASS: yoYo("+ params1.toString()+ ") -> " + result.toString(); + } + + + private static String printFailResult(Object params1, Object expected, Object result){ + String ret = "**********************" + "\n"; + ret += "FAIL: yoYo("+ params1.toString()+ ") -> " + result.toString() + + " Expected: "+ expected.toString(); + ret += "\n" + "**********************"; + return ret; + } +} \ No newline at end of file diff --git a/Ahmad/2_puzzles/assignment_17/.classpath b/Ahmad/2_puzzles/assignment_17/.classpath new file mode 100644 index 0000000..57bca72 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_17/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Ahmad/2_puzzles/assignment_17/.gitignore b/Ahmad/2_puzzles/assignment_17/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_17/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/2_puzzles/assignment_17/.project b/Ahmad/2_puzzles/assignment_17/.project new file mode 100644 index 0000000..93a391d --- /dev/null +++ b/Ahmad/2_puzzles/assignment_17/.project @@ -0,0 +1,17 @@ + + + assignment_17 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Ahmad/2_puzzles/assignment_17/.settings/org.eclipse.core.resources.prefs b/Ahmad/2_puzzles/assignment_17/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_17/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/Ahmad/2_puzzles/assignment_17/.settings/org.eclipse.jdt.core.prefs b/Ahmad/2_puzzles/assignment_17/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..8c9943d --- /dev/null +++ b/Ahmad/2_puzzles/assignment_17/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/Ahmad/2_puzzles/assignment_17/src/assignment_17/App.java b/Ahmad/2_puzzles/assignment_17/src/assignment_17/App.java new file mode 100644 index 0000000..f094dae --- /dev/null +++ b/Ahmad/2_puzzles/assignment_17/src/assignment_17/App.java @@ -0,0 +1,55 @@ +package assignment_17; + +import ignore.TestingUtils; + +public class App { + + + /** + * + + Given a string, compute recursively a new string where all the + lowercase 'o' chars have been moved to the end of the string. + +
+
+ + * EXPECTATIONS:
+ endoo("oore") ---> reoo
+ endoo("oohoi") ---> hiooo
+ endoo("oanotgo") ---> antgooo
+ */ + + public static String endoo(String str) { + + // complete the body of this method + if(str.equals("")) + return str; + + if(str.charAt(0) == 'o') + return endoo(str.substring(1)) + 'o'; + + else + return str.charAt(0) + endoo(str.substring(1)); + + } + + + + + + + + + + + + + + //----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// + public static void main(String args[]){ + TestingUtils.runTests(); + + } +} + diff --git a/Ahmad/2_puzzles/assignment_17/src/ignore/TestingUtils.java b/Ahmad/2_puzzles/assignment_17/src/ignore/TestingUtils.java new file mode 100644 index 0000000..9268991 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_17/src/ignore/TestingUtils.java @@ -0,0 +1,37 @@ +package ignore; + +import assignment_17.App; + +public class TestingUtils { + public static void runTests(){ + + + String[] params1 = { "oore", "oohioo", "ohiohio", "hiy", "h", "", "o", + "oo", "boo", "boao", "aoaoao", "oohoi", "oanotgo"}; + + String[] expected = { "reoo", "hioooo", "hihiooo", "hiy", "h", "", "o", + "oo", "boo", "baoo", "aaaooo", "hiooo", "antgooo" }; + + for(int i=0; i < params1.length; i++){ + String result = App.endoo(params1[i]); + if(result.equals(expected[i])) { + System.out.println(printPassResult(params1[i], expected[i], result)); + } else{ + System.out.println(printFailResult(params1[i], expected[i], result)); + } + } + } + + private static String printPassResult(Object params1, Object expected, Object result){ + return "PASS: endoo("+ params1.toString()+ ") -> " + result.toString(); + } + + + private static String printFailResult(Object params1, Object expected, Object result){ + String ret = "**********************" + "\n"; + ret += "FAIL: endoo("+ params1.toString()+ ") -> " + result.toString() + + " Expected: "+ expected.toString(); + ret += "\n" + "**********************"; + return ret; + } +} \ No newline at end of file diff --git a/Ahmad/2_puzzles/assignment_18/.classpath b/Ahmad/2_puzzles/assignment_18/.classpath new file mode 100644 index 0000000..57bca72 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_18/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Ahmad/2_puzzles/assignment_18/.gitignore b/Ahmad/2_puzzles/assignment_18/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_18/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/2_puzzles/assignment_18/.project b/Ahmad/2_puzzles/assignment_18/.project new file mode 100644 index 0000000..a47c0f3 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_18/.project @@ -0,0 +1,17 @@ + + + assignment_18 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Ahmad/2_puzzles/assignment_18/.settings/org.eclipse.core.resources.prefs b/Ahmad/2_puzzles/assignment_18/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_18/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/Ahmad/2_puzzles/assignment_18/.settings/org.eclipse.jdt.core.prefs b/Ahmad/2_puzzles/assignment_18/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..8c9943d --- /dev/null +++ b/Ahmad/2_puzzles/assignment_18/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/Ahmad/2_puzzles/assignment_18/src/assignment_18/App.java b/Ahmad/2_puzzles/assignment_18/src/assignment_18/App.java new file mode 100644 index 0000000..6f0e0ab --- /dev/null +++ b/Ahmad/2_puzzles/assignment_18/src/assignment_18/App.java @@ -0,0 +1,55 @@ +package assignment_18; + +import ignore.TestingUtils; + +public class App { + + + /** + * + + Given a string, compute recursively a new string where identical chars + that are adjacent in the original string are separated from each other by a "-". + +
+
+ + * EXPECTATIONS:
+ repeatHyphen("hello") ---> hel-lo
+ repeatHyphen("xxyy") ---> x-xy-y
+ repeatHyphen("aaaa") ---> a-a-a-a
+ */ + + public static String hyphenSplit(String str) { + + // complete the body of this method + if(str.length() < 2) { + return str; + } + + if(str.charAt(0) == str.charAt(1)) { + return str.charAt(0) + "-" + hyphenSplit(str.substring(1)); + } + + return str.charAt(0) + hyphenSplit(str.substring(1)); + } + + + + + + + + + + + + + + //----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// + public static void main(String args[]){ + TestingUtils.runTests(); + + } +} + diff --git a/Ahmad/2_puzzles/assignment_18/src/ignore/TestingUtils.java b/Ahmad/2_puzzles/assignment_18/src/ignore/TestingUtils.java new file mode 100644 index 0000000..c19f5d8 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_18/src/ignore/TestingUtils.java @@ -0,0 +1,37 @@ +package ignore; + +import assignment_18.App; + +public class TestingUtils { + public static void runTests(){ + + + String[] params1 = { "hello", "xxyy", "aaaa", "aaab", "aa", "a", "", + "noadjacent", "abba", "abbba"}; + + String[] expected = { "hel-lo", "x-xy-y", "a-a-a-a", "a-a-ab", "a-a", "a", "", + "noadjacent", "ab-ba", "ab-b-ba"}; + + for(int i=0; i < params1.length; i++){ + String result = App.hyphenSplit(params1[i]); + if(result.equals(expected[i])) { + System.out.println(printPassResult(params1[i], expected[i], result)); + } else{ + System.out.println(printFailResult(params1[i], expected[i], result)); + } + } + } + + private static String printPassResult(Object params1, Object expected, Object result){ + return "PASS: hyphenSplit("+ params1.toString()+ ") -> " + result.toString(); + } + + + private static String printFailResult(Object params1, Object expected, Object result){ + String ret = "**********************" + "\n"; + ret += "FAIL: hyphenSplit("+ params1.toString()+ ") -> " + result.toString() + + " Expected: "+ expected.toString(); + ret += "\n" + "**********************"; + return ret; + } +} \ No newline at end of file diff --git a/Ahmad/2_puzzles/assignment_19/.classpath b/Ahmad/2_puzzles/assignment_19/.classpath new file mode 100644 index 0000000..57bca72 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_19/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Ahmad/2_puzzles/assignment_19/.gitignore b/Ahmad/2_puzzles/assignment_19/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_19/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/2_puzzles/assignment_19/.project b/Ahmad/2_puzzles/assignment_19/.project new file mode 100644 index 0000000..24241d2 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_19/.project @@ -0,0 +1,17 @@ + + + assignment_19 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Ahmad/2_puzzles/assignment_19/.settings/org.eclipse.core.resources.prefs b/Ahmad/2_puzzles/assignment_19/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_19/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/Ahmad/2_puzzles/assignment_19/.settings/org.eclipse.jdt.core.prefs b/Ahmad/2_puzzles/assignment_19/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..8c9943d --- /dev/null +++ b/Ahmad/2_puzzles/assignment_19/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/Ahmad/2_puzzles/assignment_19/src/assignment_19/App.java b/Ahmad/2_puzzles/assignment_19/src/assignment_19/App.java new file mode 100644 index 0000000..a90646f --- /dev/null +++ b/Ahmad/2_puzzles/assignment_19/src/assignment_19/App.java @@ -0,0 +1,53 @@ +package assignment_19; + +import ignore.TestingUtils; + +public class App { + + + /** + * + + Given a string that contains a single pair of brackets, compute recursively a new string made of + only of the brackets and their contents, so "xyz[abc]123" yields "[abc]". + +
+
+ + * EXPECTATIONS:
+ insideBrackets("xyz[abc]123") ---> [abc]
+ insideBrackets("x[hello]") ---> [hello]
+ insideBrackets("[xy]1") ---> [xy]
+ */ + + public static String insideBrackets(String str) { + + // complete the body of this method + if(str.charAt(0) != '[') + return insideBrackets(str.substring(1)); + + if(str.charAt(str.length() - 1) != ']') + return insideBrackets(str.substring(0, str.length() -1)); + + return str; + } + + + + + + + + + + + + + + //----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// + public static void main(String args[]){ + TestingUtils.runTests(); + + } +} + diff --git a/Ahmad/2_puzzles/assignment_19/src/ignore/TestingUtils.java b/Ahmad/2_puzzles/assignment_19/src/ignore/TestingUtils.java new file mode 100644 index 0000000..0245395 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_19/src/ignore/TestingUtils.java @@ -0,0 +1,38 @@ +package ignore; + +import assignment_19.App; + +public class TestingUtils { + public static void runTests(){ + + + String[] params1 = { "xyz[abc]123", "x[hello]", "[xy]1", "not really [possible]", "[abc]", "[abc]xyz", "[abc]x", + "[x]", "[]", "res [ipsa] loquitor", "hello[not really]there", "ab[ab]ab"}; + + String[] expected = { "[abc]", "[hello]", "[xy]", "[possible]", "[abc]", "[abc]", "[abc]", + "[x]", "[]", "[ipsa]", "[not really]", "[ab]"}; + + + for(int i=0; i < params1.length; i++){ + String result = App.insideBrackets(params1[i]); + if(result.equals(expected[i])) { + System.out.println(printPassResult(params1[i], expected[i], result)); + } else{ + System.out.println(printFailResult(params1[i], expected[i], result)); + } + } + } + + private static String printPassResult(Object params1, Object expected, Object result){ + return "PASS: insideBrackets("+ params1.toString()+ ") -> " + result.toString(); + } + + + private static String printFailResult(Object params1, Object expected, Object result){ + String ret = "**********************" + "\n"; + ret += "FAIL: insideBrackets("+ params1.toString()+ ") -> " + result.toString() + + " Expected: "+ expected.toString(); + ret += "\n" + "**********************"; + return ret; + } +} \ No newline at end of file diff --git a/Ahmad/2_puzzles/assignment_n/.classpath b/Ahmad/2_puzzles/assignment_n/.classpath new file mode 100644 index 0000000..57bca72 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_n/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Ahmad/2_puzzles/assignment_n/.gitignore b/Ahmad/2_puzzles/assignment_n/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_n/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/puzzles/prereq-practice/src/.project b/Ahmad/2_puzzles/assignment_n/.project similarity index 92% rename from Ahmad/puzzles/prereq-practice/src/.project rename to Ahmad/2_puzzles/assignment_n/.project index 0f6f6a7..f4c113f 100644 --- a/Ahmad/puzzles/prereq-practice/src/.project +++ b/Ahmad/2_puzzles/assignment_n/.project @@ -1,6 +1,6 @@ - src + assignment_n diff --git a/Ahmad/2_puzzles/assignment_n/.settings/org.eclipse.core.resources.prefs b/Ahmad/2_puzzles/assignment_n/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_n/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/Ahmad/2_puzzles/assignment_n/.settings/org.eclipse.jdt.core.prefs b/Ahmad/2_puzzles/assignment_n/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..8c9943d --- /dev/null +++ b/Ahmad/2_puzzles/assignment_n/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/Ahmad/2_puzzles/assignment_n/src/assignment_n/App.java b/Ahmad/2_puzzles/assignment_n/src/assignment_n/App.java new file mode 100644 index 0000000..635bb70 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_n/src/assignment_n/App.java @@ -0,0 +1,34 @@ +package assignment_n; + + +import ignore.TestingUtils; + +public class App { + + /** + * Add both parameters (a & b) together and + * subtract the number 3 and return the result
+ *
+ * + * EXPECTATIONS:
+ sumMinus3(2, 5) ---> 4
+ sumMinus3(2, 1) ---> 0
+ sumMinus3(0, 2) ---> -1
+ */ + public static int sumMinus3(int a, int b) { + + return a+b-3; + } + + + + + + + +//----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// + public static void main(String args[]){ + TestingUtils.runTests(); + } + +} diff --git a/Ahmad/2_puzzles/assignment_n/src/ignore/TestingUtils.java b/Ahmad/2_puzzles/assignment_n/src/ignore/TestingUtils.java new file mode 100644 index 0000000..a659c5f --- /dev/null +++ b/Ahmad/2_puzzles/assignment_n/src/ignore/TestingUtils.java @@ -0,0 +1,37 @@ +package ignore; + +import assignment_n.App; + +public class TestingUtils { + + public static void runTests(){ + + int [] params1 = {2,0,7,3,1}; + int [] params2 = {1,3,4,5,2}; + + int [] expected = {0,0,8,5,0}; + + for(int i=0; i < params1.length; i++){ + int result = App.sumMinus3(params1[i], params2[i]); + if(result == expected[i]) { + System.out.println(printPassResult(params1[i], params2[i], expected[i], result)); + } else{ + System.out.println(printFailResult(params1[i], params2[i], expected[i], result)); + } + } + } + + private static String printPassResult(Object params1, Object params2, Object expected, Object result){ + return "PASS: sumMinus3("+ params1.toString()+ ", "+ params2.toString()+ ") -> " + result.toString(); + } + + + private static String printFailResult(Object params1, Object params2, Object expected, Object result){ + String ret = "**********************" + "\n"; + ret += "FAIL: sumMinus3("+ params1.toString()+ ", "+ params2.toString()+ ") -> " + result.toString() + + " Expected: "+ expected.toString(); + ret += "\n" + "**********************"; + return ret; + } + +} diff --git a/Ahmad/2_puzzles/assignment_n/src/module-info.java b/Ahmad/2_puzzles/assignment_n/src/module-info.java new file mode 100644 index 0000000..25f26ce --- /dev/null +++ b/Ahmad/2_puzzles/assignment_n/src/module-info.java @@ -0,0 +1,8 @@ +/** + * + */ +/** + * + */ +module assignment_20 { +} \ No newline at end of file diff --git a/Ahmad/puzzles/assignment_01/.classpath b/Ahmad/puzzles/assignment_01/.classpath deleted file mode 100644 index 51a8bba..0000000 --- a/Ahmad/puzzles/assignment_01/.classpath +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/Ahmad/puzzles/assignment_01/.settings/org.eclipse.jdt.core.prefs b/Ahmad/puzzles/assignment_01/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 3a21537..0000000 --- a/Ahmad/puzzles/assignment_01/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,11 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.8 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Ahmad/puzzles/assignment_01/src/assignment_01/.classpath b/Ahmad/puzzles/assignment_01/src/assignment_01/.classpath deleted file mode 100644 index fb565a5..0000000 --- a/Ahmad/puzzles/assignment_01/src/assignment_01/.classpath +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/Ahmad/puzzles/assignment_01/src/assignment_01/.settings/org.eclipse.jdt.core.prefs b/Ahmad/puzzles/assignment_01/src/assignment_01/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 7341ab1..0000000 --- a/Ahmad/puzzles/assignment_01/src/assignment_01/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,11 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.7 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.7 diff --git a/Ahmad/puzzles/assignment_01/src/assignment_01/App.java b/Ahmad/puzzles/assignment_01/src/assignment_01/App.java deleted file mode 100644 index 8e01f22..0000000 --- a/Ahmad/puzzles/assignment_01/src/assignment_01/App.java +++ /dev/null @@ -1,39 +0,0 @@ -package assignment_01; - -import ignore.TestingUtils; - -public class App { - - /** - Given a string of odd length, return the middle 3 characters from the string, - so the string "Monitor" yields "nit". - If the string length is less than 3, return the string as is.

- - EXPECTATIONS:
- middleThree("bunny") ---> "unn"
- middleThree("peter") ---> "ete"
- middleThree("Jamaica") --->"mai"
- */ - - public static String middleThree(String str) { - String result = str; - - if(str.length() >= 3) { - int midIdx = str.length()/2; - result = str.substring(midIdx-1, midIdx + 2); - } - - return result; - } - - - - - - - -//----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// - public static void main(String args[]){ - TestingUtils.runTests(); - } -} diff --git a/Ahmad/puzzles/assignment_06/.classpath b/Ahmad/puzzles/assignment_06/.classpath deleted file mode 100644 index 6ee61f2..0000000 --- a/Ahmad/puzzles/assignment_06/.classpath +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/Ahmad/puzzles/assignment_06/.settings/org.eclipse.jdt.core.prefs b/Ahmad/puzzles/assignment_06/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 021167a..0000000 --- a/Ahmad/puzzles/assignment_06/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,12 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=9 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=9 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.release=enabled -org.eclipse.jdt.core.compiler.source=9 diff --git a/Ahmad/puzzles/assignment_07/.classpath b/Ahmad/puzzles/assignment_07/.classpath deleted file mode 100644 index 6ee61f2..0000000 --- a/Ahmad/puzzles/assignment_07/.classpath +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/Ahmad/puzzles/assignment_07/.settings/org.eclipse.jdt.core.prefs b/Ahmad/puzzles/assignment_07/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 021167a..0000000 --- a/Ahmad/puzzles/assignment_07/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,12 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=9 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=9 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.release=enabled -org.eclipse.jdt.core.compiler.source=9 diff --git a/Ahmad/puzzles/assignment_08/.classpath b/Ahmad/puzzles/assignment_08/.classpath deleted file mode 100644 index 6ee61f2..0000000 --- a/Ahmad/puzzles/assignment_08/.classpath +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/Ahmad/puzzles/assignment_08/.settings/org.eclipse.jdt.core.prefs b/Ahmad/puzzles/assignment_08/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 021167a..0000000 --- a/Ahmad/puzzles/assignment_08/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,12 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=9 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=9 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.release=enabled -org.eclipse.jdt.core.compiler.source=9 diff --git a/Ahmad/puzzles/assignment_09/.classpath b/Ahmad/puzzles/assignment_09/.classpath deleted file mode 100644 index 6ee61f2..0000000 --- a/Ahmad/puzzles/assignment_09/.classpath +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/Ahmad/puzzles/assignment_09/.settings/org.eclipse.jdt.core.prefs b/Ahmad/puzzles/assignment_09/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 021167a..0000000 --- a/Ahmad/puzzles/assignment_09/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,12 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=9 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=9 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.release=enabled -org.eclipse.jdt.core.compiler.source=9 diff --git a/Ahmad/puzzles/assignment_10/.classpath b/Ahmad/puzzles/assignment_10/.classpath deleted file mode 100644 index 6ee61f2..0000000 --- a/Ahmad/puzzles/assignment_10/.classpath +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/Ahmad/puzzles/assignment_10/.settings/org.eclipse.jdt.core.prefs b/Ahmad/puzzles/assignment_10/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 021167a..0000000 --- a/Ahmad/puzzles/assignment_10/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,12 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=9 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=9 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.release=enabled -org.eclipse.jdt.core.compiler.source=9 diff --git a/Ahmad/puzzles/prereq-practice/.classpath b/Ahmad/puzzles/prereq-practice/.classpath deleted file mode 100644 index 51a8bba..0000000 --- a/Ahmad/puzzles/prereq-practice/.classpath +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/Ahmad/puzzles/prereq-practice/.settings/org.eclipse.jdt.core.prefs b/Ahmad/puzzles/prereq-practice/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 3a21537..0000000 --- a/Ahmad/puzzles/prereq-practice/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,11 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.8 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Ahmad/puzzles/prereq-practice/src/.classpath b/Ahmad/puzzles/prereq-practice/src/.classpath deleted file mode 100644 index 3f3893a..0000000 --- a/Ahmad/puzzles/prereq-practice/src/.classpath +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/Ahmad/puzzles/prereq-practice/src/practice/arrays/.gitignore b/Ahmad/puzzles/prereq-practice/src/practice/arrays/.gitignore deleted file mode 100644 index fa7a13d..0000000 --- a/Ahmad/puzzles/prereq-practice/src/practice/arrays/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/ArraysPractice.class diff --git a/Ahmad/puzzles/prereq-practice/src/practice/arrays/ArraysPractice.java b/Ahmad/puzzles/prereq-practice/src/practice/arrays/ArraysPractice.java deleted file mode 100644 index 070cfe7..0000000 --- a/Ahmad/puzzles/prereq-practice/src/practice/arrays/ArraysPractice.java +++ /dev/null @@ -1,24 +0,0 @@ -package practice.arrays; - -public class ArraysPractice { - - public static void main(String[] args) { - - System.out.println(search(new int[] {2,3,4,5,6,7}, 5)); - System.out.println(search(new int[] {2,3,4,5,6,7}, 9)); - - } - - public static int search(int[] nums, int target) { - - int ret = -1; - for(int i=0; i=0; i--) { -// System.out.println("char: " + name.charAt(i)); -// } - - - } -} diff --git a/Ahmad/puzzles/prereq-practice/src/practice/loops/LoopsPractice.java b/Ahmad/puzzles/prereq-practice/src/practice/loops/LoopsPractice.java deleted file mode 100644 index 661ca86..0000000 --- a/Ahmad/puzzles/prereq-practice/src/practice/loops/LoopsPractice.java +++ /dev/null @@ -1,27 +0,0 @@ -package practice.loops; - -public class LoopsPractice { - - public static void main(String[] args) { - - String str = "We have a large inventory of things inour warehouse falling in " - + "the category:apparel and the slightly " - + "more in demand category:makeup along with the category:furniture and ..."; - - printCategories(str); - } - - - - public static void printCategories(String string) { - int i = 0; - while(true) { - int found = string.indexOf("category:", i); - if (found == -1) break; - int start = found + 9; // start of category - int end = string.indexOf(" ", start); - System.out.println(string.substring(start, end)); - i = end+1; - } - } -} \ No newline at end of file diff --git a/Ahmad/puzzles/prereq-practice/src/practice/recursion/.gitignore b/Ahmad/puzzles/prereq-practice/src/practice/recursion/.gitignore deleted file mode 100644 index 7f4d8d7..0000000 --- a/Ahmad/puzzles/prereq-practice/src/practice/recursion/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/RecursionPractice.class -/RecursionPractice2.class diff --git a/Ahmad/puzzles/prereq-practice/src/practice/recursion/RecursionPractice.java b/Ahmad/puzzles/prereq-practice/src/practice/recursion/RecursionPractice.java deleted file mode 100644 index 5174fde..0000000 --- a/Ahmad/puzzles/prereq-practice/src/practice/recursion/RecursionPractice.java +++ /dev/null @@ -1,18 +0,0 @@ -package practice.recursion; - -public class RecursionPractice { - - public static void main(String[] args) { - - printNumber(4); - } - - public static int printNumber(int num) { - if(num ==0) { - return 0; - } else { - System.out.println(num); - return printNumber(num-1); - } - } -} diff --git a/Ahmad/puzzles/prereq-practice/src/practice/recursion/RecursionPractice2.java b/Ahmad/puzzles/prereq-practice/src/practice/recursion/RecursionPractice2.java deleted file mode 100644 index b45422f..0000000 --- a/Ahmad/puzzles/prereq-practice/src/practice/recursion/RecursionPractice2.java +++ /dev/null @@ -1,19 +0,0 @@ -package practice.recursion; - -public class RecursionPractice2 { - - public static void main(String[] args) { - - System.out.println(allDollars("hello")); //h$e$l$l$o - System.out.println(allDollars("James")); //j$a$m$e$s - - } - - public static String allDollars(String str) { - if(str.length() <=1) { - return str; - } - return str.charAt(0) + "$" + allDollars(str.substring(1)); - } - -} diff --git a/Ahmad/puzzles/prereq-practice/src/strings/.gitignore b/Ahmad/puzzles/prereq-practice/src/strings/.gitignore deleted file mode 100644 index d3b160f..0000000 --- a/Ahmad/puzzles/prereq-practice/src/strings/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/StringsPractice.class diff --git a/Ahmad/puzzles/prereq-practice/src/strings/StringsPractice.java b/Ahmad/puzzles/prereq-practice/src/strings/StringsPractice.java deleted file mode 100644 index 0fe3f74..0000000 --- a/Ahmad/puzzles/prereq-practice/src/strings/StringsPractice.java +++ /dev/null @@ -1,17 +0,0 @@ -package strings; - -public class StringsPractice { - - public static void main(String[] args) { - - System.out.println(dogTrouble(true, 6)); // true - System.out.println(dogTrouble(true, 7)); // false - System.out.println(dogTrouble(false, 6)); // false - } - - public static boolean dogTrouble(boolean barking, int hour) { - return (barking && (hour < 7 || hour > 20)); - } - -} - \ No newline at end of file diff --git a/Short/Short_JavaProjects/src/utilities/.gitignore b/Short/Short_JavaProjects/src/utilities/.gitignore new file mode 100644 index 0000000..e5b7768 --- /dev/null +++ b/Short/Short_JavaProjects/src/utilities/.gitignore @@ -0,0 +1 @@ +/CSV.class