From 0681740d1b988f04245168ddfedf0b189fed92d3 Mon Sep 17 00:00:00 2001 From: Gourav B Date: Wed, 12 Aug 2020 23:10:23 -0400 Subject: [PATCH 01/14] nested for|if loops: 11 - 15 --- Ahmad/puzzles/assignment_11/.classpath | 6 ++ Ahmad/puzzles/assignment_11/.gitignore | 1 + Ahmad/puzzles/assignment_11/.project | 17 +++++ .../.settings/org.eclipse.jdt.core.prefs | 11 +++ .../assignment_11/src/assignment_11/App.java | 45 ++++++++++++ .../src/ignore/TestingUtils.java | 34 +++++++++ Ahmad/puzzles/assignment_12/.classpath | 6 ++ Ahmad/puzzles/assignment_12/.gitignore | 1 + Ahmad/puzzles/assignment_12/.project | 17 +++++ .../.settings/org.eclipse.jdt.core.prefs | 11 +++ .../assignment_12/src/assignment_12/App.java | 70 +++++++++++++++++++ .../src/ignore/TestingUtils.java | 36 ++++++++++ Ahmad/puzzles/assignment_13/.classpath | 6 ++ Ahmad/puzzles/assignment_13/.gitignore | 1 + Ahmad/puzzles/assignment_13/.project | 17 +++++ .../.settings/org.eclipse.jdt.core.prefs | 11 +++ .../assignment_13/src/assignment_13/App.java | 47 +++++++++++++ .../src/ignore/TestingUtils.java | 41 +++++++++++ Ahmad/puzzles/assignment_14/.classpath | 6 ++ Ahmad/puzzles/assignment_14/.gitignore | 1 + Ahmad/puzzles/assignment_14/.project | 17 +++++ .../.settings/org.eclipse.jdt.core.prefs | 11 +++ .../assignment_14/src/assignment_14/App.java | 55 +++++++++++++++ .../src/ignore/TestingUtils.java | 45 ++++++++++++ Ahmad/puzzles/assignment_15/.classpath | 6 ++ Ahmad/puzzles/assignment_15/.gitignore | 1 + Ahmad/puzzles/assignment_15/.project | 17 +++++ .../.settings/org.eclipse.jdt.core.prefs | 11 +++ .../assignment_15/src/assignment_15/App.java | 57 +++++++++++++++ .../src/ignore/TestingUtils.java | 36 ++++++++++ 30 files changed, 641 insertions(+) create mode 100644 Ahmad/puzzles/assignment_11/.classpath create mode 100644 Ahmad/puzzles/assignment_11/.gitignore create mode 100644 Ahmad/puzzles/assignment_11/.project create mode 100644 Ahmad/puzzles/assignment_11/.settings/org.eclipse.jdt.core.prefs create mode 100644 Ahmad/puzzles/assignment_11/src/assignment_11/App.java create mode 100644 Ahmad/puzzles/assignment_11/src/ignore/TestingUtils.java create mode 100644 Ahmad/puzzles/assignment_12/.classpath create mode 100644 Ahmad/puzzles/assignment_12/.gitignore create mode 100644 Ahmad/puzzles/assignment_12/.project create mode 100644 Ahmad/puzzles/assignment_12/.settings/org.eclipse.jdt.core.prefs create mode 100644 Ahmad/puzzles/assignment_12/src/assignment_12/App.java create mode 100644 Ahmad/puzzles/assignment_12/src/ignore/TestingUtils.java create mode 100644 Ahmad/puzzles/assignment_13/.classpath create mode 100644 Ahmad/puzzles/assignment_13/.gitignore create mode 100644 Ahmad/puzzles/assignment_13/.project create mode 100644 Ahmad/puzzles/assignment_13/.settings/org.eclipse.jdt.core.prefs create mode 100644 Ahmad/puzzles/assignment_13/src/assignment_13/App.java create mode 100644 Ahmad/puzzles/assignment_13/src/ignore/TestingUtils.java create mode 100644 Ahmad/puzzles/assignment_14/.classpath create mode 100644 Ahmad/puzzles/assignment_14/.gitignore create mode 100644 Ahmad/puzzles/assignment_14/.project create mode 100644 Ahmad/puzzles/assignment_14/.settings/org.eclipse.jdt.core.prefs create mode 100644 Ahmad/puzzles/assignment_14/src/assignment_14/App.java create mode 100644 Ahmad/puzzles/assignment_14/src/ignore/TestingUtils.java create mode 100644 Ahmad/puzzles/assignment_15/.classpath create mode 100644 Ahmad/puzzles/assignment_15/.gitignore create mode 100644 Ahmad/puzzles/assignment_15/.project create mode 100644 Ahmad/puzzles/assignment_15/.settings/org.eclipse.jdt.core.prefs create mode 100644 Ahmad/puzzles/assignment_15/src/assignment_15/App.java create mode 100644 Ahmad/puzzles/assignment_15/src/ignore/TestingUtils.java diff --git a/Ahmad/puzzles/assignment_11/.classpath b/Ahmad/puzzles/assignment_11/.classpath new file mode 100644 index 0000000..51a8bba --- /dev/null +++ b/Ahmad/puzzles/assignment_11/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Ahmad/puzzles/assignment_11/.gitignore b/Ahmad/puzzles/assignment_11/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/puzzles/assignment_11/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/puzzles/assignment_11/.project b/Ahmad/puzzles/assignment_11/.project new file mode 100644 index 0000000..7eb9a73 --- /dev/null +++ b/Ahmad/puzzles/assignment_11/.project @@ -0,0 +1,17 @@ + + + assignment_11 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Ahmad/puzzles/assignment_11/.settings/org.eclipse.jdt.core.prefs b/Ahmad/puzzles/assignment_11/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..3a21537 --- /dev/null +++ b/Ahmad/puzzles/assignment_11/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +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_11/src/assignment_11/App.java b/Ahmad/puzzles/assignment_11/src/assignment_11/App.java new file mode 100644 index 0000000..296a33e --- /dev/null +++ b/Ahmad/puzzles/assignment_11/src/assignment_11/App.java @@ -0,0 +1,45 @@ +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 doubled = new String(); + if(str.length() == 0) return str; + for(int i=0; i < str.length(); i++) { + doubled += str.substring(i, i+1) + str.substring(i, i+1); + } + return doubled; + + } + + + + + + + + + + //----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// + public static void main(String args[]){ + TestingUtils.runTests(); + + } +} diff --git a/Ahmad/puzzles/assignment_11/src/ignore/TestingUtils.java b/Ahmad/puzzles/assignment_11/src/ignore/TestingUtils.java new file mode 100644 index 0000000..a244dc2 --- /dev/null +++ b/Ahmad/puzzles/assignment_11/src/ignore/TestingUtils.java @@ -0,0 +1,34 @@ +package ignore; + +import assignment_11.App; + +public class TestingUtils { + public static void runTests(){ + + String[] params1 = { "The", "AAbb", "Hi-There", "Word!", "!!", "", "a", ".", "aa" }; + + String[] expected = { "TThhee", "AAAAbbbb", "HHii--TThheerree", "WWoorrdd!!", "!!!!", "", "aa", "..", "aaaa" }; + + for(int i=0; i < params1.length; i++){ + String result = App.repeatChar(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: repeatChar("+ params1.toString()+ ") -> " + result.toString(); + } + + + private static String printFailResult(Object params1, Object expected, Object result){ + String ret = "**********************" + "\n"; + ret += "FAIL: repeatChar("+ params1.toString()+") -> " + result.toString() + + " Expected: "+ expected.toString(); + ret += "\n" + "**********************"; + return ret; + } +} \ No newline at end of file diff --git a/Ahmad/puzzles/assignment_12/.classpath b/Ahmad/puzzles/assignment_12/.classpath new file mode 100644 index 0000000..51a8bba --- /dev/null +++ b/Ahmad/puzzles/assignment_12/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Ahmad/puzzles/assignment_12/.gitignore b/Ahmad/puzzles/assignment_12/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/puzzles/assignment_12/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/puzzles/assignment_12/.project b/Ahmad/puzzles/assignment_12/.project new file mode 100644 index 0000000..c5b011e --- /dev/null +++ b/Ahmad/puzzles/assignment_12/.project @@ -0,0 +1,17 @@ + + + assignment_12 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Ahmad/puzzles/assignment_12/.settings/org.eclipse.jdt.core.prefs b/Ahmad/puzzles/assignment_12/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..3a21537 --- /dev/null +++ b/Ahmad/puzzles/assignment_12/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +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_12/src/assignment_12/App.java b/Ahmad/puzzles/assignment_12/src/assignment_12/App.java new file mode 100644 index 0000000..0009c84 --- /dev/null +++ b/Ahmad/puzzles/assignment_12/src/assignment_12/App.java @@ -0,0 +1,70 @@ +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) { + + // char star = '*'; + + int len = str.length(); + String result = ""; + + for ( int i = 0; i < len; i++) { + + + // if first char of string is not star + // append char to result + if (i == 0 && str.charAt(i) != '*') + result += str.charAt(i); + + // for every char after first, does not equal star + // or char before is not star + // append char to res + if (i > 0 && str.charAt(i) != '*' && str.charAt(i - 1) != '*') + result += str.charAt(i); + + // if char at i = star and charBefore is not star + // res = substring of first char to charBefore star + 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/puzzles/assignment_12/src/ignore/TestingUtils.java b/Ahmad/puzzles/assignment_12/src/ignore/TestingUtils.java new file mode 100644 index 0000000..44664a1 --- /dev/null +++ b/Ahmad/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/puzzles/assignment_13/.classpath b/Ahmad/puzzles/assignment_13/.classpath new file mode 100644 index 0000000..51a8bba --- /dev/null +++ b/Ahmad/puzzles/assignment_13/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Ahmad/puzzles/assignment_13/.gitignore b/Ahmad/puzzles/assignment_13/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/puzzles/assignment_13/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/puzzles/assignment_13/.project b/Ahmad/puzzles/assignment_13/.project new file mode 100644 index 0000000..46bb0f6 --- /dev/null +++ b/Ahmad/puzzles/assignment_13/.project @@ -0,0 +1,17 @@ + + + assignment_13 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Ahmad/puzzles/assignment_13/.settings/org.eclipse.jdt.core.prefs b/Ahmad/puzzles/assignment_13/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..3a21537 --- /dev/null +++ b/Ahmad/puzzles/assignment_13/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +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_13/src/assignment_13/App.java b/Ahmad/puzzles/assignment_13/src/assignment_13/App.java new file mode 100644 index 0000000..801aa44 --- /dev/null +++ b/Ahmad/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(String word: words) { + if(word.length() == len) { + count = count + 1; + } + } + + return count; + } + + + + + + + + + + + + //----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// + public static void main(String args[]){ + TestingUtils.runTests(); + + } +} diff --git a/Ahmad/puzzles/assignment_13/src/ignore/TestingUtils.java b/Ahmad/puzzles/assignment_13/src/ignore/TestingUtils.java new file mode 100644 index 0000000..b6c1c0b --- /dev/null +++ b/Ahmad/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/puzzles/assignment_14/.classpath b/Ahmad/puzzles/assignment_14/.classpath new file mode 100644 index 0000000..51a8bba --- /dev/null +++ b/Ahmad/puzzles/assignment_14/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Ahmad/puzzles/assignment_14/.gitignore b/Ahmad/puzzles/assignment_14/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/puzzles/assignment_14/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/puzzles/assignment_14/.project b/Ahmad/puzzles/assignment_14/.project new file mode 100644 index 0000000..15f497d --- /dev/null +++ b/Ahmad/puzzles/assignment_14/.project @@ -0,0 +1,17 @@ + + + assignment_14 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Ahmad/puzzles/assignment_14/.settings/org.eclipse.jdt.core.prefs b/Ahmad/puzzles/assignment_14/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..3a21537 --- /dev/null +++ b/Ahmad/puzzles/assignment_14/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +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_14/src/assignment_14/App.java b/Ahmad/puzzles/assignment_14/src/assignment_14/App.java new file mode 100644 index 0000000..7a79631 --- /dev/null +++ b/Ahmad/puzzles/assignment_14/src/assignment_14/App.java @@ -0,0 +1,55 @@ +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 < b.length; i++) { + String aString = a[i]; + String bString = b[i]; + + if (!aString.contentEquals("") && !bString.contentEquals("")) { + if(aString.charAt(0) == bString.charAt(0)) + count++; + } + } + + return count; + } + + + + + + + + + + + + //----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// + public static void main(String args[]){ + TestingUtils.runTests(); + + } +} diff --git a/Ahmad/puzzles/assignment_14/src/ignore/TestingUtils.java b/Ahmad/puzzles/assignment_14/src/ignore/TestingUtils.java new file mode 100644 index 0000000..2f452c6 --- /dev/null +++ b/Ahmad/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/puzzles/assignment_15/.classpath b/Ahmad/puzzles/assignment_15/.classpath new file mode 100644 index 0000000..51a8bba --- /dev/null +++ b/Ahmad/puzzles/assignment_15/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Ahmad/puzzles/assignment_15/.gitignore b/Ahmad/puzzles/assignment_15/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/puzzles/assignment_15/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/puzzles/assignment_15/.project b/Ahmad/puzzles/assignment_15/.project new file mode 100644 index 0000000..ce2a280 --- /dev/null +++ b/Ahmad/puzzles/assignment_15/.project @@ -0,0 +1,17 @@ + + + assignment_15 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Ahmad/puzzles/assignment_15/.settings/org.eclipse.jdt.core.prefs b/Ahmad/puzzles/assignment_15/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..3a21537 --- /dev/null +++ b/Ahmad/puzzles/assignment_15/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +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_15/src/assignment_15/App.java b/Ahmad/puzzles/assignment_15/src/assignment_15/App.java new file mode 100644 index 0000000..f21a0f8 --- /dev/null +++ b/Ahmad/puzzles/assignment_15/src/assignment_15/App.java @@ -0,0 +1,57 @@ +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()-1; 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/puzzles/assignment_15/src/ignore/TestingUtils.java b/Ahmad/puzzles/assignment_15/src/ignore/TestingUtils.java new file mode 100644 index 0000000..a6e9675 --- /dev/null +++ b/Ahmad/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 From d209a00b5efb5d7c4487f04ba8a0f9af8c0a730d Mon Sep 17 00:00:00 2001 From: possibilitiesInTest Date: Tue, 5 Dec 2023 17:49:08 -0500 Subject: [PATCH 02/14] practice while loops --- Ahmad/puzzles/practice_methods/.classpath | 6 ++++ Ahmad/puzzles/practice_methods/.gitignore | 1 + Ahmad/puzzles/practice_methods/.project | 17 +++++++++++ .../.settings/org.eclipse.jdt.core.prefs | 12 ++++++++ .../src/practice/loops/LoopsPractice.java | 29 +++++++++++++++++++ .../src/practice_methods/Hello.java | 10 +++++++ 6 files changed, 75 insertions(+) create mode 100644 Ahmad/puzzles/practice_methods/.classpath create mode 100644 Ahmad/puzzles/practice_methods/.gitignore create mode 100644 Ahmad/puzzles/practice_methods/.project create mode 100644 Ahmad/puzzles/practice_methods/.settings/org.eclipse.jdt.core.prefs create mode 100644 Ahmad/puzzles/practice_methods/src/practice/loops/LoopsPractice.java create mode 100644 Ahmad/puzzles/practice_methods/src/practice_methods/Hello.java diff --git a/Ahmad/puzzles/practice_methods/.classpath b/Ahmad/puzzles/practice_methods/.classpath new file mode 100644 index 0000000..51a8bba --- /dev/null +++ b/Ahmad/puzzles/practice_methods/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Ahmad/puzzles/practice_methods/.gitignore b/Ahmad/puzzles/practice_methods/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/puzzles/practice_methods/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/puzzles/practice_methods/.project b/Ahmad/puzzles/practice_methods/.project new file mode 100644 index 0000000..733730a --- /dev/null +++ b/Ahmad/puzzles/practice_methods/.project @@ -0,0 +1,17 @@ + + + practice_methods + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Ahmad/puzzles/practice_methods/.settings/org.eclipse.jdt.core.prefs b/Ahmad/puzzles/practice_methods/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..ec1937b --- /dev/null +++ b/Ahmad/puzzles/practice_methods/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,12 @@ +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.release=disabled +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Ahmad/puzzles/practice_methods/src/practice/loops/LoopsPractice.java b/Ahmad/puzzles/practice_methods/src/practice/loops/LoopsPractice.java new file mode 100644 index 0000000..7167c6a --- /dev/null +++ b/Ahmad/puzzles/practice_methods/src/practice/loops/LoopsPractice.java @@ -0,0 +1,29 @@ +package practice.loops; + +public class LoopsPractice { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + String str = "We have a large inventory of items in our 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; + } + } + +} diff --git a/Ahmad/puzzles/practice_methods/src/practice_methods/Hello.java b/Ahmad/puzzles/practice_methods/src/practice_methods/Hello.java new file mode 100644 index 0000000..7e71b23 --- /dev/null +++ b/Ahmad/puzzles/practice_methods/src/practice_methods/Hello.java @@ -0,0 +1,10 @@ +package practice_methods; + +public class Hello { + + public static void main(String[] args) { + // TODO Auto-generated method stub + System.out.println("Words"); + } + +} From b3f15e91986dd5a2bd6962b174a66a8fd130088e Mon Sep 17 00:00:00 2001 From: possibilitiesInTest Date: Tue, 5 Dec 2023 18:15:04 -0500 Subject: [PATCH 03/14] nested for loops example --- Ahmad/puzzles/.gitignore | 1 + Ahmad/puzzles/assignment_01/.classpath | 6 -- Ahmad/puzzles/assignment_01/.gitignore | 1 - Ahmad/puzzles/assignment_01/.project | 17 ----- .../.settings/org.eclipse.jdt.core.prefs | 11 --- .../src/assignment_01/.classpath | 6 -- .../assignment_01/src/assignment_01/.project | 17 ----- .../.settings/org.eclipse.jdt.core.prefs | 11 --- .../assignment_01/src/assignment_01/App.java | 39 ----------- .../src/ignore/TestingUtils.java | 34 --------- Ahmad/puzzles/assignment_02/.classpath | 10 --- Ahmad/puzzles/assignment_02/.gitignore | 1 - Ahmad/puzzles/assignment_02/.project | 17 ----- .../.settings/org.eclipse.jdt.core.prefs | 12 ---- .../assignment_02/src/assignment_02/App.java | 70 ------------------- .../src/ignore/TestingUtils.java | 37 ---------- Ahmad/puzzles/assignment_03/.classpath | 10 --- Ahmad/puzzles/assignment_03/.gitignore | 1 - Ahmad/puzzles/assignment_03/.project | 17 ----- .../.settings/org.eclipse.jdt.core.prefs | 12 ---- .../assignment_03/src/assignment_03/App.java | 42 ----------- .../src/ignore/TestingUtils.java | 39 ----------- Ahmad/puzzles/assignment_04/.classpath | 10 --- Ahmad/puzzles/assignment_04/.gitignore | 1 - Ahmad/puzzles/assignment_04/.project | 17 ----- .../.settings/org.eclipse.jdt.core.prefs | 12 ---- .../assignment_04/src/assignment_04/App.java | 47 ------------- .../src/ignore/TestingUtils.java | 37 ---------- Ahmad/puzzles/assignment_05/.classpath | 10 --- Ahmad/puzzles/assignment_05/.gitignore | 1 - Ahmad/puzzles/assignment_05/.project | 17 ----- .../.settings/org.eclipse.jdt.core.prefs | 12 ---- .../assignment_05/src/assignment_05/App.java | 51 -------------- .../src/ignore/TestingUtils.java | 41 ----------- Ahmad/puzzles/assignment_06/.classpath | 10 --- Ahmad/puzzles/assignment_06/.gitignore | 1 - Ahmad/puzzles/assignment_06/.project | 17 ----- .../.settings/org.eclipse.jdt.core.prefs | 12 ---- .../assignment_06/src/assignment_06/App.java | 42 ----------- .../src/ignore/TestingUtils.java | 35 ---------- Ahmad/puzzles/assignment_07/.classpath | 10 --- Ahmad/puzzles/assignment_07/.gitignore | 1 - Ahmad/puzzles/assignment_07/.project | 17 ----- .../.settings/org.eclipse.jdt.core.prefs | 12 ---- .../assignment_07/src/assignment_07/App.java | 62 ---------------- .../src/ignore/TestingUtils.java | 35 ---------- Ahmad/puzzles/assignment_08/.classpath | 10 --- Ahmad/puzzles/assignment_08/.gitignore | 1 - Ahmad/puzzles/assignment_08/.project | 17 ----- .../.settings/org.eclipse.jdt.core.prefs | 12 ---- .../assignment_08/src/assignment_08/App.java | 61 ---------------- .../src/ignore/TestingUtils.java | 39 ----------- Ahmad/puzzles/assignment_09/.classpath | 10 --- Ahmad/puzzles/assignment_09/.gitignore | 1 - Ahmad/puzzles/assignment_09/.project | 17 ----- .../.settings/org.eclipse.jdt.core.prefs | 12 ---- .../assignment_09/src/assignment_09/App.java | 66 ----------------- .../src/ignore/TestingUtils.java | 37 ---------- Ahmad/puzzles/assignment_10/.classpath | 10 --- Ahmad/puzzles/assignment_10/.gitignore | 1 - Ahmad/puzzles/assignment_10/.project | 17 ----- .../.settings/org.eclipse.jdt.core.prefs | 12 ---- .../assignment_10/src/assignment_10/App.java | 52 -------------- .../src/ignore/TestingUtils.java | 38 ---------- .../src/practice/loops/LoopsPractice2.java | 14 ++++ Ahmad/puzzles/prereq-practice/.classpath | 6 -- Ahmad/puzzles/prereq-practice/.project | 17 ----- .../.settings/org.eclipse.jdt.core.prefs | 11 --- Ahmad/puzzles/prereq-practice/src/.classpath | 6 -- Ahmad/puzzles/prereq-practice/src/.project | 17 ----- .../src/practice/arrays/.gitignore | 1 - .../src/practice/arrays/ArraysPractice.java | 24 ------- .../src/practice/loops/.gitignore | 2 - .../src/practice/loops/Loops2.java | 20 ------ .../src/practice/loops/LoopsPractice.java | 27 ------- .../src/practice/recursion/.gitignore | 2 - .../practice/recursion/RecursionPractice.java | 18 ----- .../recursion/RecursionPractice2.java | 19 ----- .../prereq-practice/src/strings/.gitignore | 1 - .../src/strings/StringsPractice.java | 17 ----- Ahmad/puzzles/puzzles/.gitignore | 1 - Ahmad/puzzles/puzzles/.project | 17 ----- 82 files changed, 15 insertions(+), 1539 deletions(-) delete mode 100644 Ahmad/puzzles/assignment_01/.classpath delete mode 100644 Ahmad/puzzles/assignment_01/.gitignore delete mode 100644 Ahmad/puzzles/assignment_01/.project delete mode 100644 Ahmad/puzzles/assignment_01/.settings/org.eclipse.jdt.core.prefs delete mode 100644 Ahmad/puzzles/assignment_01/src/assignment_01/.classpath delete mode 100644 Ahmad/puzzles/assignment_01/src/assignment_01/.project delete mode 100644 Ahmad/puzzles/assignment_01/src/assignment_01/.settings/org.eclipse.jdt.core.prefs delete mode 100644 Ahmad/puzzles/assignment_01/src/assignment_01/App.java delete mode 100644 Ahmad/puzzles/assignment_01/src/ignore/TestingUtils.java delete mode 100644 Ahmad/puzzles/assignment_02/.classpath delete mode 100644 Ahmad/puzzles/assignment_02/.gitignore delete mode 100644 Ahmad/puzzles/assignment_02/.project delete mode 100644 Ahmad/puzzles/assignment_02/.settings/org.eclipse.jdt.core.prefs delete mode 100644 Ahmad/puzzles/assignment_02/src/assignment_02/App.java delete mode 100644 Ahmad/puzzles/assignment_02/src/ignore/TestingUtils.java delete mode 100644 Ahmad/puzzles/assignment_03/.classpath delete mode 100644 Ahmad/puzzles/assignment_03/.gitignore delete mode 100644 Ahmad/puzzles/assignment_03/.project delete mode 100644 Ahmad/puzzles/assignment_03/.settings/org.eclipse.jdt.core.prefs delete mode 100644 Ahmad/puzzles/assignment_03/src/assignment_03/App.java delete mode 100644 Ahmad/puzzles/assignment_03/src/ignore/TestingUtils.java delete mode 100644 Ahmad/puzzles/assignment_04/.classpath delete mode 100644 Ahmad/puzzles/assignment_04/.gitignore delete mode 100644 Ahmad/puzzles/assignment_04/.project delete mode 100644 Ahmad/puzzles/assignment_04/.settings/org.eclipse.jdt.core.prefs delete mode 100644 Ahmad/puzzles/assignment_04/src/assignment_04/App.java delete mode 100644 Ahmad/puzzles/assignment_04/src/ignore/TestingUtils.java delete mode 100644 Ahmad/puzzles/assignment_05/.classpath delete mode 100644 Ahmad/puzzles/assignment_05/.gitignore delete mode 100644 Ahmad/puzzles/assignment_05/.project delete mode 100644 Ahmad/puzzles/assignment_05/.settings/org.eclipse.jdt.core.prefs delete mode 100644 Ahmad/puzzles/assignment_05/src/assignment_05/App.java delete mode 100644 Ahmad/puzzles/assignment_05/src/ignore/TestingUtils.java delete mode 100644 Ahmad/puzzles/assignment_06/.classpath delete mode 100644 Ahmad/puzzles/assignment_06/.gitignore delete mode 100644 Ahmad/puzzles/assignment_06/.project delete mode 100644 Ahmad/puzzles/assignment_06/.settings/org.eclipse.jdt.core.prefs delete mode 100644 Ahmad/puzzles/assignment_06/src/assignment_06/App.java delete mode 100644 Ahmad/puzzles/assignment_06/src/ignore/TestingUtils.java delete mode 100644 Ahmad/puzzles/assignment_07/.classpath delete mode 100644 Ahmad/puzzles/assignment_07/.gitignore delete mode 100644 Ahmad/puzzles/assignment_07/.project delete mode 100644 Ahmad/puzzles/assignment_07/.settings/org.eclipse.jdt.core.prefs delete mode 100644 Ahmad/puzzles/assignment_07/src/assignment_07/App.java delete mode 100644 Ahmad/puzzles/assignment_07/src/ignore/TestingUtils.java delete mode 100644 Ahmad/puzzles/assignment_08/.classpath delete mode 100644 Ahmad/puzzles/assignment_08/.gitignore delete mode 100644 Ahmad/puzzles/assignment_08/.project delete mode 100644 Ahmad/puzzles/assignment_08/.settings/org.eclipse.jdt.core.prefs delete mode 100644 Ahmad/puzzles/assignment_08/src/assignment_08/App.java delete mode 100644 Ahmad/puzzles/assignment_08/src/ignore/TestingUtils.java delete mode 100644 Ahmad/puzzles/assignment_09/.classpath delete mode 100644 Ahmad/puzzles/assignment_09/.gitignore delete mode 100644 Ahmad/puzzles/assignment_09/.project delete mode 100644 Ahmad/puzzles/assignment_09/.settings/org.eclipse.jdt.core.prefs delete mode 100644 Ahmad/puzzles/assignment_09/src/assignment_09/App.java delete mode 100644 Ahmad/puzzles/assignment_09/src/ignore/TestingUtils.java delete mode 100644 Ahmad/puzzles/assignment_10/.classpath delete mode 100644 Ahmad/puzzles/assignment_10/.gitignore delete mode 100644 Ahmad/puzzles/assignment_10/.project delete mode 100644 Ahmad/puzzles/assignment_10/.settings/org.eclipse.jdt.core.prefs delete mode 100644 Ahmad/puzzles/assignment_10/src/assignment_10/App.java delete mode 100644 Ahmad/puzzles/assignment_10/src/ignore/TestingUtils.java create mode 100644 Ahmad/puzzles/practice_methods/src/practice/loops/LoopsPractice2.java delete mode 100644 Ahmad/puzzles/prereq-practice/.classpath delete mode 100644 Ahmad/puzzles/prereq-practice/.project delete mode 100644 Ahmad/puzzles/prereq-practice/.settings/org.eclipse.jdt.core.prefs delete mode 100644 Ahmad/puzzles/prereq-practice/src/.classpath delete mode 100644 Ahmad/puzzles/prereq-practice/src/.project delete mode 100644 Ahmad/puzzles/prereq-practice/src/practice/arrays/.gitignore delete mode 100644 Ahmad/puzzles/prereq-practice/src/practice/arrays/ArraysPractice.java delete mode 100644 Ahmad/puzzles/prereq-practice/src/practice/loops/.gitignore delete mode 100644 Ahmad/puzzles/prereq-practice/src/practice/loops/Loops2.java delete mode 100644 Ahmad/puzzles/prereq-practice/src/practice/loops/LoopsPractice.java delete mode 100644 Ahmad/puzzles/prereq-practice/src/practice/recursion/.gitignore delete mode 100644 Ahmad/puzzles/prereq-practice/src/practice/recursion/RecursionPractice.java delete mode 100644 Ahmad/puzzles/prereq-practice/src/practice/recursion/RecursionPractice2.java delete mode 100644 Ahmad/puzzles/prereq-practice/src/strings/.gitignore delete mode 100644 Ahmad/puzzles/prereq-practice/src/strings/StringsPractice.java delete mode 100644 Ahmad/puzzles/puzzles/.gitignore delete mode 100644 Ahmad/puzzles/puzzles/.project diff --git a/Ahmad/puzzles/.gitignore b/Ahmad/puzzles/.gitignore index e10e727..6d90329 100644 --- a/Ahmad/puzzles/.gitignore +++ b/Ahmad/puzzles/.gitignore @@ -1 +1,2 @@ /.metadata/ +/.metadata/ 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/.gitignore b/Ahmad/puzzles/assignment_01/.gitignore deleted file mode 100644 index ae3c172..0000000 --- a/Ahmad/puzzles/assignment_01/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/bin/ diff --git a/Ahmad/puzzles/assignment_01/.project b/Ahmad/puzzles/assignment_01/.project deleted file mode 100644 index d85502a..0000000 --- a/Ahmad/puzzles/assignment_01/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - assignment_01 - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - 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/.project b/Ahmad/puzzles/assignment_01/src/assignment_01/.project deleted file mode 100644 index d85502a..0000000 --- a/Ahmad/puzzles/assignment_01/src/assignment_01/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - assignment_01 - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - 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_01/src/ignore/TestingUtils.java b/Ahmad/puzzles/assignment_01/src/ignore/TestingUtils.java deleted file mode 100644 index 00bf896..0000000 --- a/Ahmad/puzzles/assignment_01/src/ignore/TestingUtils.java +++ /dev/null @@ -1,34 +0,0 @@ -package ignore; - -import assignment_01.App; - -public class TestingUtils { - public static void runTests(){ - - - String [] params1 = {"12345","apple","tiger","candy","add","ad","a","","del","denny","sfveaadelbb"}; - String [] expected = {"234","ppl","ige","and","add","ad","a","","del","enn","aad"}; - - for(int i=0; i < params1.length; i++){ - String result = App.middleThree(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: middleThree("+ params1.toString()+ ") -> " + result.toString(); - } - - - private static String printFailResult(Object params1, Object expected, Object result){ - String ret = "**********************" + "\n"; - ret += "FAIL: middleThree("+ params1.toString()+ ") -> " + result.toString() - + " Expected: "+ expected.toString(); - ret += "\n" + "**********************"; - return ret; - } -} \ No newline at end of file diff --git a/Ahmad/puzzles/assignment_02/.classpath b/Ahmad/puzzles/assignment_02/.classpath deleted file mode 100644 index 6ee61f2..0000000 --- a/Ahmad/puzzles/assignment_02/.classpath +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/Ahmad/puzzles/assignment_02/.gitignore b/Ahmad/puzzles/assignment_02/.gitignore deleted file mode 100644 index ae3c172..0000000 --- a/Ahmad/puzzles/assignment_02/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/bin/ diff --git a/Ahmad/puzzles/assignment_02/.project b/Ahmad/puzzles/assignment_02/.project deleted file mode 100644 index 721d129..0000000 --- a/Ahmad/puzzles/assignment_02/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - assignment_02 - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/Ahmad/puzzles/assignment_02/.settings/org.eclipse.jdt.core.prefs b/Ahmad/puzzles/assignment_02/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 021167a..0000000 --- a/Ahmad/puzzles/assignment_02/.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_02/src/assignment_02/App.java b/Ahmad/puzzles/assignment_02/src/assignment_02/App.java deleted file mode 100644 index e786618..0000000 --- a/Ahmad/puzzles/assignment_02/src/assignment_02/App.java +++ /dev/null @@ -1,70 +0,0 @@ -package assignment_02; - -import ignore.TestingUtils; - -public class App { - - - /** - * You are driving a little too fast, and a police officer stops you. - * Write code to compute the fine you would have to pay. - * If your speed is 60 or less, the result is 0 since there is no fine. - * If speed is between 61 and 80 inclusive, the fine is 100 dollars. - * If speed is 81 or more, the result is 200. - * Unless it is a holiday -- on that day, your speed can be 5 higher in all cases.
- *
- * - * EXPECTATIONS:
- speedingFine(60, false) ---> 0
- speedingFine (65, false) ---> 100
- speedingFine (65, true) ---> 0
- */ - 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 fine = 0; - - if(isHoliday) { - minSpeed += 5; - maxSpeed += 5; - } - - if(speed >= maxSpeed) - fine = 200; - if(speed <= minSpeed) - fine = 0; - if(speed > minSpeed && speed <= maxSpeed) - fine = 100; - - return fine; - } - - - - - - - - - - - //----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// - public static void main(String args[]){ - TestingUtils.runTests(); - } - - -} diff --git a/Ahmad/puzzles/assignment_02/src/ignore/TestingUtils.java b/Ahmad/puzzles/assignment_02/src/ignore/TestingUtils.java deleted file mode 100644 index b905171..0000000 --- a/Ahmad/puzzles/assignment_02/src/ignore/TestingUtils.java +++ /dev/null @@ -1,37 +0,0 @@ -package ignore; - -import assignment_02.App; - -public class TestingUtils { - public static void runTests(){ - - - int [] params1 = {60,65,65,80,85,85,70,75,75,40,40,90}; - - boolean[] params2 = { false, false, true, false, false, true, false, false, true, false, true, false }; - - int[] expected = { 0, 100, 0, 100, 200, 100, 100, 100, 100, 0, 0, 200 }; - - for(int i=0; i < params1.length; i++){ - int result = App.speedingFine(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: speedingFine("+ params1.toString()+ ", "+ params2.toString()+ ") -> " + result.toString(); - } - - - private static String printFailResult(Object params1, Object params2, Object expected, Object result){ - String ret = "**********************" + "\n"; - ret += "FAIL: speedingFine("+ params1.toString()+ ", "+ params2.toString()+ ") -> " + result.toString() - + " Expected: "+ expected.toString(); - ret += "\n" + "**********************"; - return ret; - } -} \ No newline at end of file diff --git a/Ahmad/puzzles/assignment_03/.classpath b/Ahmad/puzzles/assignment_03/.classpath deleted file mode 100644 index 6ee61f2..0000000 --- a/Ahmad/puzzles/assignment_03/.classpath +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/Ahmad/puzzles/assignment_03/.gitignore b/Ahmad/puzzles/assignment_03/.gitignore deleted file mode 100644 index ae3c172..0000000 --- a/Ahmad/puzzles/assignment_03/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/bin/ diff --git a/Ahmad/puzzles/assignment_03/.project b/Ahmad/puzzles/assignment_03/.project deleted file mode 100644 index 7b70b77..0000000 --- a/Ahmad/puzzles/assignment_03/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - assignment_03 - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/Ahmad/puzzles/assignment_03/.settings/org.eclipse.jdt.core.prefs b/Ahmad/puzzles/assignment_03/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 021167a..0000000 --- a/Ahmad/puzzles/assignment_03/.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_03/src/assignment_03/App.java b/Ahmad/puzzles/assignment_03/src/assignment_03/App.java deleted file mode 100644 index df96123..0000000 --- a/Ahmad/puzzles/assignment_03/src/assignment_03/App.java +++ /dev/null @@ -1,42 +0,0 @@ -package assignment_03; - -import ignore.TestingUtils; - -public class App { - - - /** - * Given three ints, a b c, return true if it is possible to add two of - * the ints to get the third. There should only be a single line of code in the method body.
- *
- * - * EXPECTATIONS:
- twoSumOne(1, 2, 3) ---> true
- twoSumOne(3, 1, 2) ---> true
- 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); - } - - - - - - - - - - - //----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// - public static void main(String args[]){ - TestingUtils.runTests(); - } - - -} diff --git a/Ahmad/puzzles/assignment_03/src/ignore/TestingUtils.java b/Ahmad/puzzles/assignment_03/src/ignore/TestingUtils.java deleted file mode 100644 index 095c61b..0000000 --- a/Ahmad/puzzles/assignment_03/src/ignore/TestingUtils.java +++ /dev/null @@ -1,39 +0,0 @@ -package ignore; - -import assignment_03.App; - -public class TestingUtils { - public static void runTests(){ - - - int[] params1 = { 1, 3, 3, 2, 5, 5, 2, 9, 9, 5, 3, 3 }; - - int[] params2 = { 2, 1, 2, 3, 3, 3, 5, 5, 4, 4, 3, 3 }; - - int[] params3 = { 3, 2, 2, 1, -2, -3, 3, 5, 5, 9, 0, 2 }; - - boolean[] expected = { true, true, false, true, true, false, true, false, true, true, true, false }; - - for(int i=0; i < params1.length; i++){ - boolean result = App.twoSumOne(params1[i], params2[i], params3[i]); - if(result == expected[i]) { - System.out.println(printPassResult(params1[i], params2[i], params3[i], expected[i], result)); - } else{ - System.out.println(printFailResult(params1[i], params2[i], params3[i], expected[i], result)); - } - } - } - - private static String printPassResult(Object params1, Object params2, Object params3, Object expected, Object result){ - return "PASS: twoSumOne("+ params1.toString()+ ", "+ params2.toString()+ ", "+ params3.toString()+ ") -> " + result.toString(); - } - - - private static String printFailResult(Object params1, Object params2, Object params3, Object expected, Object result){ - String ret = "**********************" + "\n"; - ret += "FAIL: twoSumOne("+ params1.toString()+ ", "+ params2.toString()+", "+ params3.toString()+ ") -> " + result.toString() - + " Expected: "+ expected.toString(); - ret += "\n" + "**********************"; - return ret; - } -} \ No newline at end of file diff --git a/Ahmad/puzzles/assignment_04/.classpath b/Ahmad/puzzles/assignment_04/.classpath deleted file mode 100644 index 6ee61f2..0000000 --- a/Ahmad/puzzles/assignment_04/.classpath +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/Ahmad/puzzles/assignment_04/.gitignore b/Ahmad/puzzles/assignment_04/.gitignore deleted file mode 100644 index ae3c172..0000000 --- a/Ahmad/puzzles/assignment_04/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/bin/ diff --git a/Ahmad/puzzles/assignment_04/.project b/Ahmad/puzzles/assignment_04/.project deleted file mode 100644 index 05868e0..0000000 --- a/Ahmad/puzzles/assignment_04/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - assignment_04 - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/Ahmad/puzzles/assignment_04/.settings/org.eclipse.jdt.core.prefs b/Ahmad/puzzles/assignment_04/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 021167a..0000000 --- a/Ahmad/puzzles/assignment_04/.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_04/src/assignment_04/App.java b/Ahmad/puzzles/assignment_04/src/assignment_04/App.java deleted file mode 100644 index ef8b800..0000000 --- a/Ahmad/puzzles/assignment_04/src/assignment_04/App.java +++ /dev/null @@ -1,47 +0,0 @@ -package assignment_04; - -import ignore.TestingUtils; - -public class App { - - /** - The birds in Florida like to sing during favorable temperatures. - In particular, they sing if the temperature is between 60 and 90 (inclusive). - Unless it is summer, then the upper limit is 100 instead of 90. - Given an int temperature and a boolean isSummer, - return true if the birds are singing and false otherwise.
-
- - * EXPECTATIONS:
- birdsSinging(70, false) ---> true
- birdsSinging(95, false) ---> false
- birdsSinging(95, true) ---> true
- */ - public static boolean birdsSinging(int temp, boolean isSummer) { - - int maxTemp = 91; - int minTemp = 59; - - if(isSummer) { - maxTemp = 101; - } - - return (temp < maxTemp) && (temp > minTemp); - - } - - - - - - - - - - //----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// - public static void main(String args[]){ - TestingUtils.runTests(); - } -} - - diff --git a/Ahmad/puzzles/assignment_04/src/ignore/TestingUtils.java b/Ahmad/puzzles/assignment_04/src/ignore/TestingUtils.java deleted file mode 100644 index 3130948..0000000 --- a/Ahmad/puzzles/assignment_04/src/ignore/TestingUtils.java +++ /dev/null @@ -1,37 +0,0 @@ -package ignore; - -import assignment_04.App; - -public class TestingUtils { - public static void runTests(){ - - - int[] params1 = { 70, 95, 95, 90, 90, 50, 50, 100, 100, 105, 59, 59, 60 }; - - boolean[] params2 = { false, false, true, false, true, false, true, false, true, true, false, true, false }; - - boolean[] expected = { true, false, true, true, true, false, false, false, true, false, false, false, true }; - - for(int i=0; i < params1.length; i++){ - boolean result = App.birdsSinging(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: birdsSinging("+ params1.toString()+ ", "+ params2.toString()+ ") -> " + result.toString(); - } - - - private static String printFailResult(Object params1, Object params2, Object expected, Object result){ - String ret = "**********************" + "\n"; - ret += "FAIL: birdsSinging("+ params1.toString()+ ", "+ params2.toString()+ ") -> " + result.toString() - + " Expected: "+ expected.toString(); - ret += "\n" + "**********************"; - return ret; - } -} \ No newline at end of file diff --git a/Ahmad/puzzles/assignment_05/.classpath b/Ahmad/puzzles/assignment_05/.classpath deleted file mode 100644 index 6ee61f2..0000000 --- a/Ahmad/puzzles/assignment_05/.classpath +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/Ahmad/puzzles/assignment_05/.gitignore b/Ahmad/puzzles/assignment_05/.gitignore deleted file mode 100644 index ae3c172..0000000 --- a/Ahmad/puzzles/assignment_05/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/bin/ diff --git a/Ahmad/puzzles/assignment_05/.project b/Ahmad/puzzles/assignment_05/.project deleted file mode 100644 index 3ddfb2c..0000000 --- a/Ahmad/puzzles/assignment_05/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - assignment_05 - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/Ahmad/puzzles/assignment_05/.settings/org.eclipse.jdt.core.prefs b/Ahmad/puzzles/assignment_05/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 021167a..0000000 --- a/Ahmad/puzzles/assignment_05/.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_05/src/assignment_05/App.java b/Ahmad/puzzles/assignment_05/src/assignment_05/App.java deleted file mode 100644 index 7634398..0000000 --- a/Ahmad/puzzles/assignment_05/src/assignment_05/App.java +++ /dev/null @@ -1,51 +0,0 @@ -package assignment_05; - -import ignore.TestingUtils; - -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, - second does not need to be greater than first but still better be less than third. -
-
- - * EXPECTATIONS:
- isOrdered(1, 2, 4, false) ---> true
- isOrdered(1, 2, 1, false) ---> false
- isOrdered(1, 1, 2, true) ---> true
- */ - public static boolean isOrdered(int first, int second, int third, boolean itsOk) { - - boolean greaterThanSecond = false; - boolean greaterThanFirst = false; - - if (third > second) { - greaterThanSecond = true; - } - - if (second > first) { - greaterThanFirst = true; - } - - return (itsOk && greaterThanSecond) || (greaterThanSecond && greaterThanFirst); - } - - - - - - - - - - - - //----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// - public static void main(String args[]){ - TestingUtils.runTests(); - } -} - - diff --git a/Ahmad/puzzles/assignment_05/src/ignore/TestingUtils.java b/Ahmad/puzzles/assignment_05/src/ignore/TestingUtils.java deleted file mode 100644 index b5185ec..0000000 --- a/Ahmad/puzzles/assignment_05/src/ignore/TestingUtils.java +++ /dev/null @@ -1,41 +0,0 @@ -package ignore; - -import assignment_05.App; - -public class TestingUtils { - public static void runTests(){ - - - int[] params1 = { 1, 1, 1, 3, 2, 3, 4, 4, 2, 7, 7, 7 }; - - int[] params2 = { 2, 2, 1, 2, 3, 2, 2, 5, 4, 9, 5, 5 }; - - int[] params3 = { 4, 1, 2, 4, 4, 4, 2, 2, 6, 10, 6, 4 }; - - boolean[] params4 = { false, false, true, false, false, true, true, true, true, false, true, true }; - - boolean[] expected = { true, false, true, false, true, true, false, false, true, true, true, false }; - - for(int i=0; i < params1.length; i++){ - boolean result = App.isOrdered(params1[i], params2[i], params3[i], params4[i]); - if(result == expected[i]) { - System.out.println(printPassResult(params1[i], params2[i],params3[i], params4[i], expected[i], result)); - } else{ - System.out.println(printFailResult(params1[i], params2[i], params3[i], params4[i], expected[i], result)); - } - } - } - - private static String printPassResult(Object params1, Object params2, Object params3, Object params4, Object expected, Object result){ - return "PASS: isOrdered("+ params1.toString()+ ", "+ params2.toString()+", "+ params3.toString()+", "+ params4.toString()+ ") -> " + result.toString(); - } - - - private static String printFailResult(Object params1, Object params2, Object params3, Object params4, Object expected, Object result){ - String ret = "**********************" + "\n"; - ret += "FAIL: isOrdered("+ params1.toString()+ ", "+ params2.toString()+", "+ params3.toString()+", "+ params4.toString()+ ") -> " + result.toString() - + " Expected: "+ expected.toString(); - ret += "\n" + "**********************"; - return ret; - } -} \ No newline at end of file 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/.gitignore b/Ahmad/puzzles/assignment_06/.gitignore deleted file mode 100644 index ae3c172..0000000 --- a/Ahmad/puzzles/assignment_06/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/bin/ diff --git a/Ahmad/puzzles/assignment_06/.project b/Ahmad/puzzles/assignment_06/.project deleted file mode 100644 index 97391bf..0000000 --- a/Ahmad/puzzles/assignment_06/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - assignment_06 - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - 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_06/src/assignment_06/App.java b/Ahmad/puzzles/assignment_06/src/assignment_06/App.java deleted file mode 100644 index 44b1733..0000000 --- a/Ahmad/puzzles/assignment_06/src/assignment_06/App.java +++ /dev/null @@ -1,42 +0,0 @@ -package assignment_06; - -import ignore.TestingUtils; - -public class App { - - /** - We'll say a number is cool if it's a multiple of 11 or if it is one more than a multiple of 11. - Return true if the given non-negative number is cool. Use the % "modulus" operator - we spoke about in the prerequisite section. Watch the lesson on modulus if you need to review -
-
- - * EXPECTATIONS:
- isCool(22) ---> true
- isCool(23) ---> true
- isCool(24) ---> false
- */ - public static boolean isCool(int n) { - - return (n % 11 == 0) || (n % 11 == 1); - } - - - - - - - - - - - - - //----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// - public static void main(String args[]){ - TestingUtils.runTests(); - - } -} - - diff --git a/Ahmad/puzzles/assignment_06/src/ignore/TestingUtils.java b/Ahmad/puzzles/assignment_06/src/ignore/TestingUtils.java deleted file mode 100644 index 63f9a10..0000000 --- a/Ahmad/puzzles/assignment_06/src/ignore/TestingUtils.java +++ /dev/null @@ -1,35 +0,0 @@ -package ignore; - -import assignment_06.App; - -public class TestingUtils { - public static void runTests(){ - - - int[] params1 = { 22, 23, 24, 21, 11, 12, 10, 9, 8, 0, 1, 2, 121, 122, 123, 46, 49, 52, 54, 55 }; - boolean[] expected = { true, true, false, false, true, true, false, false, false, true, true, false, true, true, - false, false, false, false, false, true }; - - for(int i=0; i < params1.length; i++){ - boolean result = App.isCool(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: isCool("+ params1.toString()+ ") -> " + result.toString(); - } - - - private static String printFailResult(Object params1, Object expected, Object result){ - String ret = "**********************" + "\n"; - ret += "FAIL: isCool("+ params1.toString()+ ") -> " + result.toString() - + " Expected: "+ expected.toString(); - ret += "\n" + "**********************"; - return ret; - } -} \ No newline at end of file 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/.gitignore b/Ahmad/puzzles/assignment_07/.gitignore deleted file mode 100644 index ae3c172..0000000 --- a/Ahmad/puzzles/assignment_07/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/bin/ diff --git a/Ahmad/puzzles/assignment_07/.project b/Ahmad/puzzles/assignment_07/.project deleted file mode 100644 index 75ef8a6..0000000 --- a/Ahmad/puzzles/assignment_07/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - assignment_07 - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - 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_07/src/assignment_07/App.java b/Ahmad/puzzles/assignment_07/src/assignment_07/App.java deleted file mode 100644 index 5f4d3ba..0000000 --- a/Ahmad/puzzles/assignment_07/src/assignment_07/App.java +++ /dev/null @@ -1,62 +0,0 @@ -package assignment_07; - -import ignore.TestingUtils; - -public class App { - - /** - Given an int n, return the string form of the number followed by "!". - So if the int is for example 13 this method should return "13!". - However the catch is that if the number is divisible by 3 the method should return "Fizz!" - instead of the number, and if the number is divisible by 5 it should return "Buzz!", - and if divisible by both 3 and 5, use "FizzBuzz!". You’ll need to use the % "mod" - for computing the remainder after division, so 23 % 10 yields 3. - -
-
- - * EXPECTATIONS:
- fizzyWizzy(1) ---> "1!"
- fizzyWizzy(2) ---> "2!"
- 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!"; - - return n + "!"; - } - - - - - - - - - - - - - - //----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// - public static void main(String args[]){ - TestingUtils.runTests(); - - } -} - - diff --git a/Ahmad/puzzles/assignment_07/src/ignore/TestingUtils.java b/Ahmad/puzzles/assignment_07/src/ignore/TestingUtils.java deleted file mode 100644 index e91cf46..0000000 --- a/Ahmad/puzzles/assignment_07/src/ignore/TestingUtils.java +++ /dev/null @@ -1,35 +0,0 @@ -package ignore; - -import assignment_07.App; - -public class TestingUtils { - public static void runTests(){ - - - int[] params1 = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 15, 16, 18, 19, 21, 44, 45, 100 }; - String[] expected = { "1!", "2!", "Fizz!", "4!", "Buzz!", "Fizz!", "7!", "8!", "Fizz!", "FizzBuzz!", "16!", - "Fizz!", "19!", "Fizz!", "44!", "FizzBuzz!", "Buzz!" }; - - for(int i=0; i < params1.length; i++){ - String result = App.fizzyWizzy(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: fizzyWizzy("+ params1.toString()+ ") -> " + result.toString(); - } - - - private static String printFailResult(Object params1, Object expected, Object result){ - String ret = "**********************" + "\n"; - ret += "FAIL: fizzyWizzy("+ params1.toString()+ ") -> " + result.toString() - + " Expected: "+ expected.toString(); - ret += "\n" + "**********************"; - return ret; - } -} \ No newline at end of file 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/.gitignore b/Ahmad/puzzles/assignment_08/.gitignore deleted file mode 100644 index ae3c172..0000000 --- a/Ahmad/puzzles/assignment_08/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/bin/ diff --git a/Ahmad/puzzles/assignment_08/.project b/Ahmad/puzzles/assignment_08/.project deleted file mode 100644 index 1d1e6db..0000000 --- a/Ahmad/puzzles/assignment_08/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - assignment_08 - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - 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_08/src/assignment_08/App.java b/Ahmad/puzzles/assignment_08/src/assignment_08/App.java deleted file mode 100644 index d5b610d..0000000 --- a/Ahmad/puzzles/assignment_08/src/assignment_08/App.java +++ /dev/null @@ -1,61 +0,0 @@ -package assignment_08; - -import ignore.TestingUtils; - -public class App { - - - /** - - Given 3 int arguments - a, b, c, return their sum. However, if one of the arguments - is the same as any of the other ones, that number should not count towards the sum. - So basically you only sum unique numbers, not duplicates -
-
- - * EXPECTATIONS:
- sumUnique(1, 2, 3) ---> 6
- sumUnique(3, 2, 3) ---> 2
- sumUnique(3, 3, 3) ---> 0
- */ - - 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; - - return a + b + c; - } - - - - - - - - - - - - //----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// - public static void main(String args[]){ - TestingUtils.runTests(); - - } -} diff --git a/Ahmad/puzzles/assignment_08/src/ignore/TestingUtils.java b/Ahmad/puzzles/assignment_08/src/ignore/TestingUtils.java deleted file mode 100644 index 9d3ecbe..0000000 --- a/Ahmad/puzzles/assignment_08/src/ignore/TestingUtils.java +++ /dev/null @@ -1,39 +0,0 @@ -package ignore; - -import assignment_08.App; - -public class TestingUtils { - public static void runTests(){ - - - int[] params1 = { 1, 3, 3, 9, 2, 2, 2, 4, 1 }; - - int[] params2 = { 2, 2, 3, 2, 2, 9, 9, 2, 3 }; - - int[] params3 = { 3, 3, 3, 2, 9, 2, 3, 3, 1 }; - - int[] expected = { 6, 2, 0, 9, 9, 9, 14, 9, 3 }; - - for(int i=0; i < params1.length; i++){ - int result = App.sumUnique(params1[i], params2[i], params3[i]); - if(result == expected[i]) { - System.out.println(printPassResult(params1[i], params2[i], params3[i], expected[i], result)); - } else{ - System.out.println(printFailResult(params1[i], params2[i], params3[i], expected[i], result)); - } - } - } - - private static String printPassResult(Object params1, Object params2, Object params3, Object expected, Object result){ - return "PASS: sumUnique("+ params1.toString()+ ", "+ params2.toString()+ ", "+ params3.toString()+ ") -> " + result.toString(); - } - - - private static String printFailResult(Object params1, Object params2, Object params3, Object expected, Object result){ - String ret = "**********************" + "\n"; - ret += "FAIL: sumUnique("+ params1.toString()+ ", "+ params2.toString()+", "+ params3.toString()+ ") -> " + result.toString() - + " Expected: "+ expected.toString(); - ret += "\n" + "**********************"; - return ret; - } -} \ No newline at end of file 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/.gitignore b/Ahmad/puzzles/assignment_09/.gitignore deleted file mode 100644 index ae3c172..0000000 --- a/Ahmad/puzzles/assignment_09/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/bin/ diff --git a/Ahmad/puzzles/assignment_09/.project b/Ahmad/puzzles/assignment_09/.project deleted file mode 100644 index 41d732d..0000000 --- a/Ahmad/puzzles/assignment_09/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - assignment_09 - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - 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_09/src/assignment_09/App.java b/Ahmad/puzzles/assignment_09/src/assignment_09/App.java deleted file mode 100644 index 9698c59..0000000 --- a/Ahmad/puzzles/assignment_09/src/assignment_09/App.java +++ /dev/null @@ -1,66 +0,0 @@ -package assignment_09; - -import ignore.TestingUtils; - -public class App { - - - /** - - Given 2 positive int arguments (a, b), return whichever argument is - nearest to the number 21 without going over. - Return 0 if they both go over 21. -
-
- - * EXPECTATIONS:
- nearestTwentyOne(19, 21) ---> 21
- nearestTwentyOne(21, 19) ---> 21
- nearestTwentyOne(19, 22) ---> 19
- nearestTwentyOne(32, 22) ---> 0
- */ - - 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) { - return a; - } else { - return b; - } - - } - - - - - - - - - - - - - //----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// - public static void main(String args[]){ - TestingUtils.runTests(); - - } -} diff --git a/Ahmad/puzzles/assignment_09/src/ignore/TestingUtils.java b/Ahmad/puzzles/assignment_09/src/ignore/TestingUtils.java deleted file mode 100644 index 9123745..0000000 --- a/Ahmad/puzzles/assignment_09/src/ignore/TestingUtils.java +++ /dev/null @@ -1,37 +0,0 @@ -package ignore; - -import assignment_09.App; - -public class TestingUtils { - public static void runTests(){ - - - int[] params1 = { 19, 21, 19, 22, 22, 22, 33, 1, 34, 17, 18, 16, 3, 3, 21 }; - - int[] params2 = { 21, 19, 22, 19, 50, 22, 1, 2, 33, 19, 17, 23, 4, 2, 20 }; - - int[] expected = { 21, 21, 19, 19, 0, 0, 1, 2, 0, 19, 18, 16, 4, 3, 21 }; - - for(int i=0; i < params1.length; i++){ - int result = App.nearestTwentyOne(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: nearestTwentyOne("+ params1.toString()+ ", "+ params2.toString()+ ") -> " + result.toString(); - } - - - private static String printFailResult(Object params1, Object params2, Object expected, Object result){ - String ret = "**********************" + "\n"; - ret += "FAIL: nearestTwentyOne("+ params1.toString()+ ", "+ params2.toString()+ ") -> " + result.toString() - + " Expected: "+ expected.toString(); - ret += "\n" + "**********************"; - return ret; - } -} \ No newline at end of file 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/.gitignore b/Ahmad/puzzles/assignment_10/.gitignore deleted file mode 100644 index ae3c172..0000000 --- a/Ahmad/puzzles/assignment_10/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/bin/ diff --git a/Ahmad/puzzles/assignment_10/.project b/Ahmad/puzzles/assignment_10/.project deleted file mode 100644 index b1f6869..0000000 --- a/Ahmad/puzzles/assignment_10/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - assignment_10 - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - 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/assignment_10/src/assignment_10/App.java b/Ahmad/puzzles/assignment_10/src/assignment_10/App.java deleted file mode 100644 index 09c9fb6..0000000 --- a/Ahmad/puzzles/assignment_10/src/assignment_10/App.java +++ /dev/null @@ -1,52 +0,0 @@ -package assignment_10; - -import ignore.TestingUtils; - -public class App { - - - /** - - Given 3 int arguments, a b c, return their sum. However, if one of the arguments is 13 - then it does not count towards the sum and arguments to it's right do not count either. - So for example, if b is 13, then both b and c do not count. -
-
- - * EXPECTATIONS:
- partialSum(1, 2, 3) ---> 6
- partialSum(1, 2, 13) ---> 3
- partialSum(1, 13, 3) ---> 1
- */ - - 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;} - - if (a == 13) return 0; - if (b == 13) return a; - if (c == 13) return a + b; - - return a + b + c; - - } - - - - - - - - - - - - //----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// - public static void main(String args[]){ - TestingUtils.runTests(); - - } -} diff --git a/Ahmad/puzzles/assignment_10/src/ignore/TestingUtils.java b/Ahmad/puzzles/assignment_10/src/ignore/TestingUtils.java deleted file mode 100644 index 6bfb20b..0000000 --- a/Ahmad/puzzles/assignment_10/src/ignore/TestingUtils.java +++ /dev/null @@ -1,38 +0,0 @@ -package ignore; - -import assignment_10.App; - -public class TestingUtils { - public static void runTests(){ - - int[] params1 = { 1, 1, 1, 1, 6, 13, 13, 13, 9, 8, 7, 3 }; - - int[] params2 = { 2, 2, 13, 13, 5, 2, 2, 13, 4, 13, 2, 3 }; - - int[] params3 = { 3, 13, 3, 13, 2, 3, 13, 2, 13, 2, 1, 13 }; - - int[] expected = { 6, 3, 1, 1, 13, 0, 0, 0, 13, 8, 10, 6 }; - - for(int i=0; i < params1.length; i++){ - int result = App.partialSum(params1[i], params2[i], params3[i]); - if(result == expected[i]) { - System.out.println(printPassResult(params1[i], params2[i], params3[i], expected[i], result)); - } else{ - System.out.println(printFailResult(params1[i], params2[i], params3[i], expected[i], result)); - } - } - } - - private static String printPassResult(Object params1, Object params2, Object params3, Object expected, Object result){ - return "PASS: partialSum("+ params1.toString()+ ", "+ params2.toString()+ ", "+ params3.toString()+ ") -> " + result.toString(); - } - - - private static String printFailResult(Object params1, Object params2, Object params3, Object expected, Object result){ - String ret = "**********************" + "\n"; - ret += "FAIL: partialSum("+ params1.toString()+ ", "+ params2.toString()+", "+ params3.toString()+ ") -> " + result.toString() - + " Expected: "+ expected.toString(); - ret += "\n" + "**********************"; - return ret; - } -} \ No newline at end of file diff --git a/Ahmad/puzzles/practice_methods/src/practice/loops/LoopsPractice2.java b/Ahmad/puzzles/practice_methods/src/practice/loops/LoopsPractice2.java new file mode 100644 index 0000000..0eb6e0f --- /dev/null +++ b/Ahmad/puzzles/practice_methods/src/practice/loops/LoopsPractice2.java @@ -0,0 +1,14 @@ +package practice.loops; + +public class LoopsPractice2 { + + public static void main(String[] args) { + for(int idx= 0; idx < 100; idx++) { + for(int j =0; j < 10; j++) { + System.out.println("value of idx is "+ idx + " ----" + j); + + } + } + } + +} 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/.project b/Ahmad/puzzles/prereq-practice/.project deleted file mode 100644 index e3e0bf3..0000000 --- a/Ahmad/puzzles/prereq-practice/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - prereq-practice - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - 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/.project b/Ahmad/puzzles/prereq-practice/src/.project deleted file mode 100644 index 0f6f6a7..0000000 --- a/Ahmad/puzzles/prereq-practice/src/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - src - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - 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/Ahmad/puzzles/puzzles/.gitignore b/Ahmad/puzzles/puzzles/.gitignore deleted file mode 100644 index ae3c172..0000000 --- a/Ahmad/puzzles/puzzles/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/bin/ diff --git a/Ahmad/puzzles/puzzles/.project b/Ahmad/puzzles/puzzles/.project deleted file mode 100644 index 302e9f6..0000000 --- a/Ahmad/puzzles/puzzles/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - puzzles - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - From 3099e37209130a61070eb5d45c68a68dba9691a5 Mon Sep 17 00:00:00 2001 From: possibilitiesInTest Date: Mon, 26 Feb 2024 11:16:10 -0500 Subject: [PATCH 04/14] assignment_01 string middleThree chars solution --- Ahmad/2_puzzles/.gitignore | 1 + Ahmad/2_puzzles/.project | 11 ++++++ Ahmad/2_puzzles/assignment_01/.classpath | 10 +++++ Ahmad/2_puzzles/assignment_01/.gitignore | 1 + Ahmad/2_puzzles/assignment_01/.project | 17 +++++++++ .../org.eclipse.core.resources.prefs | 2 + .../.settings/org.eclipse.jdt.core.prefs | 14 +++++++ .../assignment_01/src/assignment_01/App.java | 38 +++++++++++++++++++ .../src/ignore/TestingUtils.java | 34 +++++++++++++++++ 9 files changed, 128 insertions(+) create mode 100644 Ahmad/2_puzzles/.gitignore create mode 100644 Ahmad/2_puzzles/.project create mode 100644 Ahmad/2_puzzles/assignment_01/.classpath create mode 100644 Ahmad/2_puzzles/assignment_01/.gitignore create mode 100644 Ahmad/2_puzzles/assignment_01/.project create mode 100644 Ahmad/2_puzzles/assignment_01/.settings/org.eclipse.core.resources.prefs create mode 100644 Ahmad/2_puzzles/assignment_01/.settings/org.eclipse.jdt.core.prefs create mode 100644 Ahmad/2_puzzles/assignment_01/src/assignment_01/App.java create mode 100644 Ahmad/2_puzzles/assignment_01/src/ignore/TestingUtils.java diff --git a/Ahmad/2_puzzles/.gitignore b/Ahmad/2_puzzles/.gitignore new file mode 100644 index 0000000..e10e727 --- /dev/null +++ b/Ahmad/2_puzzles/.gitignore @@ -0,0 +1 @@ +/.metadata/ 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/2_puzzles/assignment_01/.classpath b/Ahmad/2_puzzles/assignment_01/.classpath new file mode 100644 index 0000000..57bca72 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_01/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Ahmad/2_puzzles/assignment_01/.gitignore b/Ahmad/2_puzzles/assignment_01/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_01/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/2_puzzles/assignment_01/.project b/Ahmad/2_puzzles/assignment_01/.project new file mode 100644 index 0000000..d85502a --- /dev/null +++ b/Ahmad/2_puzzles/assignment_01/.project @@ -0,0 +1,17 @@ + + + assignment_01 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Ahmad/2_puzzles/assignment_01/.settings/org.eclipse.core.resources.prefs b/Ahmad/2_puzzles/assignment_01/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_01/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/Ahmad/2_puzzles/assignment_01/.settings/org.eclipse.jdt.core.prefs b/Ahmad/2_puzzles/assignment_01/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..8c9943d --- /dev/null +++ b/Ahmad/2_puzzles/assignment_01/.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_01/src/assignment_01/App.java b/Ahmad/2_puzzles/assignment_01/src/assignment_01/App.java new file mode 100644 index 0000000..6d9a81d --- /dev/null +++ b/Ahmad/2_puzzles/assignment_01/src/assignment_01/App.java @@ -0,0 +1,38 @@ +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) { + int middle = str.length() / 2; + String result = str; + + if (str.length() >= 3) { + result = str.substring(middle-1, middle+2); + } + return result; + } + + + + + + + +//----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// + public static void main(String args[]){ + TestingUtils.runTests(); + } +} diff --git a/Ahmad/2_puzzles/assignment_01/src/ignore/TestingUtils.java b/Ahmad/2_puzzles/assignment_01/src/ignore/TestingUtils.java new file mode 100644 index 0000000..00bf896 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_01/src/ignore/TestingUtils.java @@ -0,0 +1,34 @@ +package ignore; + +import assignment_01.App; + +public class TestingUtils { + public static void runTests(){ + + + String [] params1 = {"12345","apple","tiger","candy","add","ad","a","","del","denny","sfveaadelbb"}; + String [] expected = {"234","ppl","ige","and","add","ad","a","","del","enn","aad"}; + + for(int i=0; i < params1.length; i++){ + String result = App.middleThree(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: middleThree("+ params1.toString()+ ") -> " + result.toString(); + } + + + private static String printFailResult(Object params1, Object expected, Object result){ + String ret = "**********************" + "\n"; + ret += "FAIL: middleThree("+ params1.toString()+ ") -> " + result.toString() + + " Expected: "+ expected.toString(); + ret += "\n" + "**********************"; + return ret; + } +} \ No newline at end of file From 691d874d8be9011f595e23897f849e2017b73d11 Mon Sep 17 00:00:00 2001 From: possibilitiesInTest Date: Mon, 26 Feb 2024 11:16:48 -0500 Subject: [PATCH 05/14] clean up directory --- Ahmad/puzzles/.gitignore | 2 - Ahmad/puzzles/assignment_11/.classpath | 6 -- Ahmad/puzzles/assignment_11/.gitignore | 1 - Ahmad/puzzles/assignment_11/.project | 17 ----- .../.settings/org.eclipse.jdt.core.prefs | 11 --- .../assignment_11/src/assignment_11/App.java | 45 ------------ .../src/ignore/TestingUtils.java | 34 --------- Ahmad/puzzles/assignment_12/.classpath | 6 -- Ahmad/puzzles/assignment_12/.gitignore | 1 - Ahmad/puzzles/assignment_12/.project | 17 ----- .../.settings/org.eclipse.jdt.core.prefs | 11 --- .../assignment_12/src/assignment_12/App.java | 70 ------------------- .../src/ignore/TestingUtils.java | 36 ---------- Ahmad/puzzles/assignment_13/.classpath | 6 -- Ahmad/puzzles/assignment_13/.gitignore | 1 - Ahmad/puzzles/assignment_13/.project | 17 ----- .../.settings/org.eclipse.jdt.core.prefs | 11 --- .../assignment_13/src/assignment_13/App.java | 47 ------------- .../src/ignore/TestingUtils.java | 41 ----------- Ahmad/puzzles/assignment_14/.classpath | 6 -- Ahmad/puzzles/assignment_14/.gitignore | 1 - Ahmad/puzzles/assignment_14/.project | 17 ----- .../.settings/org.eclipse.jdt.core.prefs | 11 --- .../assignment_14/src/assignment_14/App.java | 55 --------------- .../src/ignore/TestingUtils.java | 45 ------------ Ahmad/puzzles/assignment_15/.classpath | 6 -- Ahmad/puzzles/assignment_15/.gitignore | 1 - Ahmad/puzzles/assignment_15/.project | 17 ----- .../.settings/org.eclipse.jdt.core.prefs | 11 --- .../assignment_15/src/assignment_15/App.java | 57 --------------- .../src/ignore/TestingUtils.java | 36 ---------- Ahmad/puzzles/practice_methods/.classpath | 6 -- Ahmad/puzzles/practice_methods/.gitignore | 1 - Ahmad/puzzles/practice_methods/.project | 17 ----- .../.settings/org.eclipse.jdt.core.prefs | 12 ---- .../src/practice/loops/LoopsPractice.java | 29 -------- .../src/practice/loops/LoopsPractice2.java | 14 ---- .../src/practice_methods/Hello.java | 10 --- Ahmad/puzzles/prereq-practice/.gitignore | 1 - .../src/utilities/.gitignore | 1 + 40 files changed, 1 insertion(+), 733 deletions(-) delete mode 100644 Ahmad/puzzles/.gitignore delete mode 100644 Ahmad/puzzles/assignment_11/.classpath delete mode 100644 Ahmad/puzzles/assignment_11/.gitignore delete mode 100644 Ahmad/puzzles/assignment_11/.project delete mode 100644 Ahmad/puzzles/assignment_11/.settings/org.eclipse.jdt.core.prefs delete mode 100644 Ahmad/puzzles/assignment_11/src/assignment_11/App.java delete mode 100644 Ahmad/puzzles/assignment_11/src/ignore/TestingUtils.java delete mode 100644 Ahmad/puzzles/assignment_12/.classpath delete mode 100644 Ahmad/puzzles/assignment_12/.gitignore delete mode 100644 Ahmad/puzzles/assignment_12/.project delete mode 100644 Ahmad/puzzles/assignment_12/.settings/org.eclipse.jdt.core.prefs delete mode 100644 Ahmad/puzzles/assignment_12/src/assignment_12/App.java delete mode 100644 Ahmad/puzzles/assignment_12/src/ignore/TestingUtils.java delete mode 100644 Ahmad/puzzles/assignment_13/.classpath delete mode 100644 Ahmad/puzzles/assignment_13/.gitignore delete mode 100644 Ahmad/puzzles/assignment_13/.project delete mode 100644 Ahmad/puzzles/assignment_13/.settings/org.eclipse.jdt.core.prefs delete mode 100644 Ahmad/puzzles/assignment_13/src/assignment_13/App.java delete mode 100644 Ahmad/puzzles/assignment_13/src/ignore/TestingUtils.java delete mode 100644 Ahmad/puzzles/assignment_14/.classpath delete mode 100644 Ahmad/puzzles/assignment_14/.gitignore delete mode 100644 Ahmad/puzzles/assignment_14/.project delete mode 100644 Ahmad/puzzles/assignment_14/.settings/org.eclipse.jdt.core.prefs delete mode 100644 Ahmad/puzzles/assignment_14/src/assignment_14/App.java delete mode 100644 Ahmad/puzzles/assignment_14/src/ignore/TestingUtils.java delete mode 100644 Ahmad/puzzles/assignment_15/.classpath delete mode 100644 Ahmad/puzzles/assignment_15/.gitignore delete mode 100644 Ahmad/puzzles/assignment_15/.project delete mode 100644 Ahmad/puzzles/assignment_15/.settings/org.eclipse.jdt.core.prefs delete mode 100644 Ahmad/puzzles/assignment_15/src/assignment_15/App.java delete mode 100644 Ahmad/puzzles/assignment_15/src/ignore/TestingUtils.java delete mode 100644 Ahmad/puzzles/practice_methods/.classpath delete mode 100644 Ahmad/puzzles/practice_methods/.gitignore delete mode 100644 Ahmad/puzzles/practice_methods/.project delete mode 100644 Ahmad/puzzles/practice_methods/.settings/org.eclipse.jdt.core.prefs delete mode 100644 Ahmad/puzzles/practice_methods/src/practice/loops/LoopsPractice.java delete mode 100644 Ahmad/puzzles/practice_methods/src/practice/loops/LoopsPractice2.java delete mode 100644 Ahmad/puzzles/practice_methods/src/practice_methods/Hello.java delete mode 100644 Ahmad/puzzles/prereq-practice/.gitignore create mode 100644 Short/Short_JavaProjects/src/utilities/.gitignore diff --git a/Ahmad/puzzles/.gitignore b/Ahmad/puzzles/.gitignore deleted file mode 100644 index 6d90329..0000000 --- a/Ahmad/puzzles/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/.metadata/ -/.metadata/ diff --git a/Ahmad/puzzles/assignment_11/.classpath b/Ahmad/puzzles/assignment_11/.classpath deleted file mode 100644 index 51a8bba..0000000 --- a/Ahmad/puzzles/assignment_11/.classpath +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/Ahmad/puzzles/assignment_11/.gitignore b/Ahmad/puzzles/assignment_11/.gitignore deleted file mode 100644 index ae3c172..0000000 --- a/Ahmad/puzzles/assignment_11/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/bin/ diff --git a/Ahmad/puzzles/assignment_11/.project b/Ahmad/puzzles/assignment_11/.project deleted file mode 100644 index 7eb9a73..0000000 --- a/Ahmad/puzzles/assignment_11/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - assignment_11 - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/Ahmad/puzzles/assignment_11/.settings/org.eclipse.jdt.core.prefs b/Ahmad/puzzles/assignment_11/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 3a21537..0000000 --- a/Ahmad/puzzles/assignment_11/.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_11/src/assignment_11/App.java b/Ahmad/puzzles/assignment_11/src/assignment_11/App.java deleted file mode 100644 index 296a33e..0000000 --- a/Ahmad/puzzles/assignment_11/src/assignment_11/App.java +++ /dev/null @@ -1,45 +0,0 @@ -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 doubled = new String(); - if(str.length() == 0) return str; - for(int i=0; i < str.length(); i++) { - doubled += str.substring(i, i+1) + str.substring(i, i+1); - } - return doubled; - - } - - - - - - - - - - //----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// - public static void main(String args[]){ - TestingUtils.runTests(); - - } -} diff --git a/Ahmad/puzzles/assignment_11/src/ignore/TestingUtils.java b/Ahmad/puzzles/assignment_11/src/ignore/TestingUtils.java deleted file mode 100644 index a244dc2..0000000 --- a/Ahmad/puzzles/assignment_11/src/ignore/TestingUtils.java +++ /dev/null @@ -1,34 +0,0 @@ -package ignore; - -import assignment_11.App; - -public class TestingUtils { - public static void runTests(){ - - String[] params1 = { "The", "AAbb", "Hi-There", "Word!", "!!", "", "a", ".", "aa" }; - - String[] expected = { "TThhee", "AAAAbbbb", "HHii--TThheerree", "WWoorrdd!!", "!!!!", "", "aa", "..", "aaaa" }; - - for(int i=0; i < params1.length; i++){ - String result = App.repeatChar(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: repeatChar("+ params1.toString()+ ") -> " + result.toString(); - } - - - private static String printFailResult(Object params1, Object expected, Object result){ - String ret = "**********************" + "\n"; - ret += "FAIL: repeatChar("+ params1.toString()+") -> " + result.toString() - + " Expected: "+ expected.toString(); - ret += "\n" + "**********************"; - return ret; - } -} \ No newline at end of file diff --git a/Ahmad/puzzles/assignment_12/.classpath b/Ahmad/puzzles/assignment_12/.classpath deleted file mode 100644 index 51a8bba..0000000 --- a/Ahmad/puzzles/assignment_12/.classpath +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/Ahmad/puzzles/assignment_12/.gitignore b/Ahmad/puzzles/assignment_12/.gitignore deleted file mode 100644 index ae3c172..0000000 --- a/Ahmad/puzzles/assignment_12/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/bin/ diff --git a/Ahmad/puzzles/assignment_12/.project b/Ahmad/puzzles/assignment_12/.project deleted file mode 100644 index c5b011e..0000000 --- a/Ahmad/puzzles/assignment_12/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - assignment_12 - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/Ahmad/puzzles/assignment_12/.settings/org.eclipse.jdt.core.prefs b/Ahmad/puzzles/assignment_12/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 3a21537..0000000 --- a/Ahmad/puzzles/assignment_12/.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_12/src/assignment_12/App.java b/Ahmad/puzzles/assignment_12/src/assignment_12/App.java deleted file mode 100644 index 0009c84..0000000 --- a/Ahmad/puzzles/assignment_12/src/assignment_12/App.java +++ /dev/null @@ -1,70 +0,0 @@ -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) { - - // char star = '*'; - - int len = str.length(); - String result = ""; - - for ( int i = 0; i < len; i++) { - - - // if first char of string is not star - // append char to result - if (i == 0 && str.charAt(i) != '*') - result += str.charAt(i); - - // for every char after first, does not equal star - // or char before is not star - // append char to res - if (i > 0 && str.charAt(i) != '*' && str.charAt(i - 1) != '*') - result += str.charAt(i); - - // if char at i = star and charBefore is not star - // res = substring of first char to charBefore star - 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/puzzles/assignment_12/src/ignore/TestingUtils.java b/Ahmad/puzzles/assignment_12/src/ignore/TestingUtils.java deleted file mode 100644 index 44664a1..0000000 --- a/Ahmad/puzzles/assignment_12/src/ignore/TestingUtils.java +++ /dev/null @@ -1,36 +0,0 @@ -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/puzzles/assignment_13/.classpath b/Ahmad/puzzles/assignment_13/.classpath deleted file mode 100644 index 51a8bba..0000000 --- a/Ahmad/puzzles/assignment_13/.classpath +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/Ahmad/puzzles/assignment_13/.gitignore b/Ahmad/puzzles/assignment_13/.gitignore deleted file mode 100644 index ae3c172..0000000 --- a/Ahmad/puzzles/assignment_13/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/bin/ diff --git a/Ahmad/puzzles/assignment_13/.project b/Ahmad/puzzles/assignment_13/.project deleted file mode 100644 index 46bb0f6..0000000 --- a/Ahmad/puzzles/assignment_13/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - assignment_13 - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/Ahmad/puzzles/assignment_13/.settings/org.eclipse.jdt.core.prefs b/Ahmad/puzzles/assignment_13/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 3a21537..0000000 --- a/Ahmad/puzzles/assignment_13/.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_13/src/assignment_13/App.java b/Ahmad/puzzles/assignment_13/src/assignment_13/App.java deleted file mode 100644 index 801aa44..0000000 --- a/Ahmad/puzzles/assignment_13/src/assignment_13/App.java +++ /dev/null @@ -1,47 +0,0 @@ -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(String word: words) { - if(word.length() == len) { - count = count + 1; - } - } - - return count; - } - - - - - - - - - - - - //----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// - public static void main(String args[]){ - TestingUtils.runTests(); - - } -} diff --git a/Ahmad/puzzles/assignment_13/src/ignore/TestingUtils.java b/Ahmad/puzzles/assignment_13/src/ignore/TestingUtils.java deleted file mode 100644 index b6c1c0b..0000000 --- a/Ahmad/puzzles/assignment_13/src/ignore/TestingUtils.java +++ /dev/null @@ -1,41 +0,0 @@ -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/puzzles/assignment_14/.classpath b/Ahmad/puzzles/assignment_14/.classpath deleted file mode 100644 index 51a8bba..0000000 --- a/Ahmad/puzzles/assignment_14/.classpath +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/Ahmad/puzzles/assignment_14/.gitignore b/Ahmad/puzzles/assignment_14/.gitignore deleted file mode 100644 index ae3c172..0000000 --- a/Ahmad/puzzles/assignment_14/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/bin/ diff --git a/Ahmad/puzzles/assignment_14/.project b/Ahmad/puzzles/assignment_14/.project deleted file mode 100644 index 15f497d..0000000 --- a/Ahmad/puzzles/assignment_14/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - assignment_14 - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/Ahmad/puzzles/assignment_14/.settings/org.eclipse.jdt.core.prefs b/Ahmad/puzzles/assignment_14/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 3a21537..0000000 --- a/Ahmad/puzzles/assignment_14/.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_14/src/assignment_14/App.java b/Ahmad/puzzles/assignment_14/src/assignment_14/App.java deleted file mode 100644 index 7a79631..0000000 --- a/Ahmad/puzzles/assignment_14/src/assignment_14/App.java +++ /dev/null @@ -1,55 +0,0 @@ -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 < b.length; i++) { - String aString = a[i]; - String bString = b[i]; - - if (!aString.contentEquals("") && !bString.contentEquals("")) { - if(aString.charAt(0) == bString.charAt(0)) - count++; - } - } - - return count; - } - - - - - - - - - - - - //----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// - public static void main(String args[]){ - TestingUtils.runTests(); - - } -} diff --git a/Ahmad/puzzles/assignment_14/src/ignore/TestingUtils.java b/Ahmad/puzzles/assignment_14/src/ignore/TestingUtils.java deleted file mode 100644 index 2f452c6..0000000 --- a/Ahmad/puzzles/assignment_14/src/ignore/TestingUtils.java +++ /dev/null @@ -1,45 +0,0 @@ -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/puzzles/assignment_15/.classpath b/Ahmad/puzzles/assignment_15/.classpath deleted file mode 100644 index 51a8bba..0000000 --- a/Ahmad/puzzles/assignment_15/.classpath +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/Ahmad/puzzles/assignment_15/.gitignore b/Ahmad/puzzles/assignment_15/.gitignore deleted file mode 100644 index ae3c172..0000000 --- a/Ahmad/puzzles/assignment_15/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/bin/ diff --git a/Ahmad/puzzles/assignment_15/.project b/Ahmad/puzzles/assignment_15/.project deleted file mode 100644 index ce2a280..0000000 --- a/Ahmad/puzzles/assignment_15/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - assignment_15 - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/Ahmad/puzzles/assignment_15/.settings/org.eclipse.jdt.core.prefs b/Ahmad/puzzles/assignment_15/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 3a21537..0000000 --- a/Ahmad/puzzles/assignment_15/.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_15/src/assignment_15/App.java b/Ahmad/puzzles/assignment_15/src/assignment_15/App.java deleted file mode 100644 index f21a0f8..0000000 --- a/Ahmad/puzzles/assignment_15/src/assignment_15/App.java +++ /dev/null @@ -1,57 +0,0 @@ -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()-1; 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/puzzles/assignment_15/src/ignore/TestingUtils.java b/Ahmad/puzzles/assignment_15/src/ignore/TestingUtils.java deleted file mode 100644 index a6e9675..0000000 --- a/Ahmad/puzzles/assignment_15/src/ignore/TestingUtils.java +++ /dev/null @@ -1,36 +0,0 @@ -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/puzzles/practice_methods/.classpath b/Ahmad/puzzles/practice_methods/.classpath deleted file mode 100644 index 51a8bba..0000000 --- a/Ahmad/puzzles/practice_methods/.classpath +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/Ahmad/puzzles/practice_methods/.gitignore b/Ahmad/puzzles/practice_methods/.gitignore deleted file mode 100644 index ae3c172..0000000 --- a/Ahmad/puzzles/practice_methods/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/bin/ diff --git a/Ahmad/puzzles/practice_methods/.project b/Ahmad/puzzles/practice_methods/.project deleted file mode 100644 index 733730a..0000000 --- a/Ahmad/puzzles/practice_methods/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - practice_methods - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/Ahmad/puzzles/practice_methods/.settings/org.eclipse.jdt.core.prefs b/Ahmad/puzzles/practice_methods/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index ec1937b..0000000 --- a/Ahmad/puzzles/practice_methods/.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=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.release=disabled -org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Ahmad/puzzles/practice_methods/src/practice/loops/LoopsPractice.java b/Ahmad/puzzles/practice_methods/src/practice/loops/LoopsPractice.java deleted file mode 100644 index 7167c6a..0000000 --- a/Ahmad/puzzles/practice_methods/src/practice/loops/LoopsPractice.java +++ /dev/null @@ -1,29 +0,0 @@ -package practice.loops; - -public class LoopsPractice { - - public static void main(String[] args) { - // TODO Auto-generated method stub - - String str = "We have a large inventory of items in our 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; - } - } - -} diff --git a/Ahmad/puzzles/practice_methods/src/practice/loops/LoopsPractice2.java b/Ahmad/puzzles/practice_methods/src/practice/loops/LoopsPractice2.java deleted file mode 100644 index 0eb6e0f..0000000 --- a/Ahmad/puzzles/practice_methods/src/practice/loops/LoopsPractice2.java +++ /dev/null @@ -1,14 +0,0 @@ -package practice.loops; - -public class LoopsPractice2 { - - public static void main(String[] args) { - for(int idx= 0; idx < 100; idx++) { - for(int j =0; j < 10; j++) { - System.out.println("value of idx is "+ idx + " ----" + j); - - } - } - } - -} diff --git a/Ahmad/puzzles/practice_methods/src/practice_methods/Hello.java b/Ahmad/puzzles/practice_methods/src/practice_methods/Hello.java deleted file mode 100644 index 7e71b23..0000000 --- a/Ahmad/puzzles/practice_methods/src/practice_methods/Hello.java +++ /dev/null @@ -1,10 +0,0 @@ -package practice_methods; - -public class Hello { - - public static void main(String[] args) { - // TODO Auto-generated method stub - System.out.println("Words"); - } - -} diff --git a/Ahmad/puzzles/prereq-practice/.gitignore b/Ahmad/puzzles/prereq-practice/.gitignore deleted file mode 100644 index ae3c172..0000000 --- a/Ahmad/puzzles/prereq-practice/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/bin/ 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 From cd7bc5165d159bac3ab0ad50d49842f7d7b337d5 Mon Sep 17 00:00:00 2001 From: possibilitiesInTest Date: Mon, 26 Feb 2024 11:34:12 -0500 Subject: [PATCH 06/14] assignment_02 min.max speed solution --- Ahmad/2_puzzles/assignment_02/.classpath | 10 ++++ Ahmad/2_puzzles/assignment_02/.gitignore | 1 + Ahmad/2_puzzles/assignment_02/.project | 17 ++++++ .../org.eclipse.core.resources.prefs | 2 + .../.settings/org.eclipse.jdt.core.prefs | 14 +++++ .../assignment_02/src/assignment_02/App.java | 59 +++++++++++++++++++ .../src/ignore/TestingUtils.java | 37 ++++++++++++ 7 files changed, 140 insertions(+) create mode 100644 Ahmad/2_puzzles/assignment_02/.classpath create mode 100644 Ahmad/2_puzzles/assignment_02/.gitignore create mode 100644 Ahmad/2_puzzles/assignment_02/.project create mode 100644 Ahmad/2_puzzles/assignment_02/.settings/org.eclipse.core.resources.prefs create mode 100644 Ahmad/2_puzzles/assignment_02/.settings/org.eclipse.jdt.core.prefs create mode 100644 Ahmad/2_puzzles/assignment_02/src/assignment_02/App.java create mode 100644 Ahmad/2_puzzles/assignment_02/src/ignore/TestingUtils.java diff --git a/Ahmad/2_puzzles/assignment_02/.classpath b/Ahmad/2_puzzles/assignment_02/.classpath new file mode 100644 index 0000000..57bca72 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_02/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Ahmad/2_puzzles/assignment_02/.gitignore b/Ahmad/2_puzzles/assignment_02/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_02/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/2_puzzles/assignment_02/.project b/Ahmad/2_puzzles/assignment_02/.project new file mode 100644 index 0000000..721d129 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_02/.project @@ -0,0 +1,17 @@ + + + assignment_02 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + 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/2_puzzles/assignment_02/.settings/org.eclipse.jdt.core.prefs b/Ahmad/2_puzzles/assignment_02/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..8c9943d --- /dev/null +++ b/Ahmad/2_puzzles/assignment_02/.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_02/src/assignment_02/App.java b/Ahmad/2_puzzles/assignment_02/src/assignment_02/App.java new file mode 100644 index 0000000..13acb2b --- /dev/null +++ b/Ahmad/2_puzzles/assignment_02/src/assignment_02/App.java @@ -0,0 +1,59 @@ +package assignment_02; + +import ignore.TestingUtils; + +public class App { + + + /** + * You are driving a little too fast, and a police officer stops you. + * Write code to compute the fine you would have to pay. + * If your speed is 60 or less, the result is 0 since there is no fine. + * If speed is between 61 and 80 inclusive, the fine is 100 dollars. + * If speed is 81 or more, the result is 200. + * Unless it is a holiday -- on that day, your speed can be 5 higher in all cases.
+ *
+ * + * EXPECTATIONS:
+ speedingFine(60, false) ---> 0
+ speedingFine (65, false) ---> 100
+ speedingFine (65, true) ---> 0
+ */ + public static int speedingFine(int speed, boolean isHoliday) { + + + int min = 60; + int max = 80; + int fine = 0; + + if (isHoliday == true) { + min += 5; + max += 5; + } + + if (speed > max){ + fine = 200; + } + if(speed > min && speed <= max) { + fine = 100; + } + + return fine; + } + + + + + + + + + + + //----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// + public static void main(String args[]){ + TestingUtils.runTests(); + } + + +} diff --git a/Ahmad/2_puzzles/assignment_02/src/ignore/TestingUtils.java b/Ahmad/2_puzzles/assignment_02/src/ignore/TestingUtils.java new file mode 100644 index 0000000..b905171 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_02/src/ignore/TestingUtils.java @@ -0,0 +1,37 @@ +package ignore; + +import assignment_02.App; + +public class TestingUtils { + public static void runTests(){ + + + int [] params1 = {60,65,65,80,85,85,70,75,75,40,40,90}; + + boolean[] params2 = { false, false, true, false, false, true, false, false, true, false, true, false }; + + int[] expected = { 0, 100, 0, 100, 200, 100, 100, 100, 100, 0, 0, 200 }; + + for(int i=0; i < params1.length; i++){ + int result = App.speedingFine(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: speedingFine("+ params1.toString()+ ", "+ params2.toString()+ ") -> " + result.toString(); + } + + + private static String printFailResult(Object params1, Object params2, Object expected, Object result){ + String ret = "**********************" + "\n"; + ret += "FAIL: speedingFine("+ params1.toString()+ ", "+ params2.toString()+ ") -> " + result.toString() + + " Expected: "+ expected.toString(); + ret += "\n" + "**********************"; + return ret; + } +} \ No newline at end of file From e16a21b8d456b196e6220b9205e56cb27aefe445 Mon Sep 17 00:00:00 2001 From: possibilitiesInTest Date: Mon, 26 Feb 2024 11:51:14 -0500 Subject: [PATCH 07/14] twoSumOne, birdsSinging, isOrdered solutions --- Ahmad/2_puzzles/assignment_03/.classpath | 10 ++++ Ahmad/2_puzzles/assignment_03/.gitignore | 1 + Ahmad/2_puzzles/assignment_03/.project | 17 ++++++ .../org.eclipse.core.resources.prefs | 2 + .../.settings/org.eclipse.jdt.core.prefs | 14 +++++ .../assignment_03/src/assignment_03/App.java | 39 ++++++++++++++ .../src/ignore/TestingUtils.java | 39 ++++++++++++++ Ahmad/2_puzzles/assignment_04/.classpath | 10 ++++ Ahmad/2_puzzles/assignment_04/.gitignore | 1 + Ahmad/2_puzzles/assignment_04/.project | 17 ++++++ .../org.eclipse.core.resources.prefs | 2 + .../.settings/org.eclipse.jdt.core.prefs | 14 +++++ .../assignment_04/src/assignment_04/App.java | 52 ++++++++++++++++++ .../src/ignore/TestingUtils.java | 37 +++++++++++++ Ahmad/2_puzzles/assignment_05/.classpath | 10 ++++ Ahmad/2_puzzles/assignment_05/.gitignore | 1 + Ahmad/2_puzzles/assignment_05/.project | 17 ++++++ .../org.eclipse.core.resources.prefs | 2 + .../.settings/org.eclipse.jdt.core.prefs | 14 +++++ .../assignment_05/src/assignment_05/App.java | 54 +++++++++++++++++++ .../src/ignore/TestingUtils.java | 41 ++++++++++++++ 21 files changed, 394 insertions(+) create mode 100644 Ahmad/2_puzzles/assignment_03/.classpath create mode 100644 Ahmad/2_puzzles/assignment_03/.gitignore create mode 100644 Ahmad/2_puzzles/assignment_03/.project create mode 100644 Ahmad/2_puzzles/assignment_03/.settings/org.eclipse.core.resources.prefs create mode 100644 Ahmad/2_puzzles/assignment_03/.settings/org.eclipse.jdt.core.prefs create mode 100644 Ahmad/2_puzzles/assignment_03/src/assignment_03/App.java create mode 100644 Ahmad/2_puzzles/assignment_03/src/ignore/TestingUtils.java create mode 100644 Ahmad/2_puzzles/assignment_04/.classpath create mode 100644 Ahmad/2_puzzles/assignment_04/.gitignore create mode 100644 Ahmad/2_puzzles/assignment_04/.project create mode 100644 Ahmad/2_puzzles/assignment_04/.settings/org.eclipse.core.resources.prefs create mode 100644 Ahmad/2_puzzles/assignment_04/.settings/org.eclipse.jdt.core.prefs create mode 100644 Ahmad/2_puzzles/assignment_04/src/assignment_04/App.java create mode 100644 Ahmad/2_puzzles/assignment_04/src/ignore/TestingUtils.java create mode 100644 Ahmad/2_puzzles/assignment_05/.classpath create mode 100644 Ahmad/2_puzzles/assignment_05/.gitignore create mode 100644 Ahmad/2_puzzles/assignment_05/.project create mode 100644 Ahmad/2_puzzles/assignment_05/.settings/org.eclipse.core.resources.prefs create mode 100644 Ahmad/2_puzzles/assignment_05/.settings/org.eclipse.jdt.core.prefs create mode 100644 Ahmad/2_puzzles/assignment_05/src/assignment_05/App.java create mode 100644 Ahmad/2_puzzles/assignment_05/src/ignore/TestingUtils.java diff --git a/Ahmad/2_puzzles/assignment_03/.classpath b/Ahmad/2_puzzles/assignment_03/.classpath new file mode 100644 index 0000000..57bca72 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_03/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Ahmad/2_puzzles/assignment_03/.gitignore b/Ahmad/2_puzzles/assignment_03/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_03/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/2_puzzles/assignment_03/.project b/Ahmad/2_puzzles/assignment_03/.project new file mode 100644 index 0000000..7b70b77 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_03/.project @@ -0,0 +1,17 @@ + + + assignment_03 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + 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/2_puzzles/assignment_03/.settings/org.eclipse.jdt.core.prefs b/Ahmad/2_puzzles/assignment_03/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..8c9943d --- /dev/null +++ b/Ahmad/2_puzzles/assignment_03/.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_03/src/assignment_03/App.java b/Ahmad/2_puzzles/assignment_03/src/assignment_03/App.java new file mode 100644 index 0000000..c595390 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_03/src/assignment_03/App.java @@ -0,0 +1,39 @@ +package assignment_03; + +import ignore.TestingUtils; + +public class App { + + + /** + * Given three ints, a b c, return true if it is possible to add two of + * the ints to get the third. There should only be a single line of code in the method body.
+ *
+ * + * EXPECTATIONS:
+ twoSumOne(1, 2, 3) ---> true
+ twoSumOne(3, 1, 2) ---> true
+ twoSumOne(3, 2, 2) ---> false
+ */ + public static boolean twoSumOne(int a, int b, int c) { + + return (a + b == c) || (b + c == a) || (a + c == b); + + } + + + + + + + + + + + //----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// + public static void main(String args[]){ + TestingUtils.runTests(); + } + + +} diff --git a/Ahmad/2_puzzles/assignment_03/src/ignore/TestingUtils.java b/Ahmad/2_puzzles/assignment_03/src/ignore/TestingUtils.java new file mode 100644 index 0000000..095c61b --- /dev/null +++ b/Ahmad/2_puzzles/assignment_03/src/ignore/TestingUtils.java @@ -0,0 +1,39 @@ +package ignore; + +import assignment_03.App; + +public class TestingUtils { + public static void runTests(){ + + + int[] params1 = { 1, 3, 3, 2, 5, 5, 2, 9, 9, 5, 3, 3 }; + + int[] params2 = { 2, 1, 2, 3, 3, 3, 5, 5, 4, 4, 3, 3 }; + + int[] params3 = { 3, 2, 2, 1, -2, -3, 3, 5, 5, 9, 0, 2 }; + + boolean[] expected = { true, true, false, true, true, false, true, false, true, true, true, false }; + + for(int i=0; i < params1.length; i++){ + boolean result = App.twoSumOne(params1[i], params2[i], params3[i]); + if(result == expected[i]) { + System.out.println(printPassResult(params1[i], params2[i], params3[i], expected[i], result)); + } else{ + System.out.println(printFailResult(params1[i], params2[i], params3[i], expected[i], result)); + } + } + } + + private static String printPassResult(Object params1, Object params2, Object params3, Object expected, Object result){ + return "PASS: twoSumOne("+ params1.toString()+ ", "+ params2.toString()+ ", "+ params3.toString()+ ") -> " + result.toString(); + } + + + private static String printFailResult(Object params1, Object params2, Object params3, Object expected, Object result){ + String ret = "**********************" + "\n"; + ret += "FAIL: twoSumOne("+ params1.toString()+ ", "+ params2.toString()+", "+ params3.toString()+ ") -> " + result.toString() + + " Expected: "+ expected.toString(); + ret += "\n" + "**********************"; + return ret; + } +} \ No newline at end of file diff --git a/Ahmad/2_puzzles/assignment_04/.classpath b/Ahmad/2_puzzles/assignment_04/.classpath new file mode 100644 index 0000000..57bca72 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_04/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Ahmad/2_puzzles/assignment_04/.gitignore b/Ahmad/2_puzzles/assignment_04/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_04/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/2_puzzles/assignment_04/.project b/Ahmad/2_puzzles/assignment_04/.project new file mode 100644 index 0000000..05868e0 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_04/.project @@ -0,0 +1,17 @@ + + + assignment_04 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + 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/2_puzzles/assignment_04/.settings/org.eclipse.jdt.core.prefs b/Ahmad/2_puzzles/assignment_04/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..8c9943d --- /dev/null +++ b/Ahmad/2_puzzles/assignment_04/.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_04/src/assignment_04/App.java b/Ahmad/2_puzzles/assignment_04/src/assignment_04/App.java new file mode 100644 index 0000000..1ba3c70 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_04/src/assignment_04/App.java @@ -0,0 +1,52 @@ +package assignment_04; + +import ignore.TestingUtils; + +public class App { + + /** + The birds in Florida like to sing during favorable temperatures. + In particular, they sing if the temperature is between 60 and 90 (inclusive). + Unless it is summer, then the upper limit is 100 instead of 90. + Given an int temperature and a boolean isSummer, + return true if the birds are singing and false otherwise.
+
+ + * EXPECTATIONS:
+ birdsSinging(70, false) ---> true
+ birdsSinging(95, false) ---> false
+ birdsSinging(95, true) ---> true
+ */ + public static boolean birdsSinging(int temp, boolean isSummer) { + + int min = 60; + int max = 90; + boolean singing = false; + + if (isSummer) { + max += 10; + } + + if (temp >= min && temp <= max) { + singing = true; + } + + + return singing; + } + + + + + + + + + + //----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// + public static void main(String args[]){ + TestingUtils.runTests(); + } +} + + diff --git a/Ahmad/2_puzzles/assignment_04/src/ignore/TestingUtils.java b/Ahmad/2_puzzles/assignment_04/src/ignore/TestingUtils.java new file mode 100644 index 0000000..3130948 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_04/src/ignore/TestingUtils.java @@ -0,0 +1,37 @@ +package ignore; + +import assignment_04.App; + +public class TestingUtils { + public static void runTests(){ + + + int[] params1 = { 70, 95, 95, 90, 90, 50, 50, 100, 100, 105, 59, 59, 60 }; + + boolean[] params2 = { false, false, true, false, true, false, true, false, true, true, false, true, false }; + + boolean[] expected = { true, false, true, true, true, false, false, false, true, false, false, false, true }; + + for(int i=0; i < params1.length; i++){ + boolean result = App.birdsSinging(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: birdsSinging("+ params1.toString()+ ", "+ params2.toString()+ ") -> " + result.toString(); + } + + + private static String printFailResult(Object params1, Object params2, Object expected, Object result){ + String ret = "**********************" + "\n"; + ret += "FAIL: birdsSinging("+ params1.toString()+ ", "+ params2.toString()+ ") -> " + result.toString() + + " Expected: "+ expected.toString(); + ret += "\n" + "**********************"; + return ret; + } +} \ No newline at end of file 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/2_puzzles/assignment_05/.gitignore b/Ahmad/2_puzzles/assignment_05/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_05/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/2_puzzles/assignment_05/.project b/Ahmad/2_puzzles/assignment_05/.project new file mode 100644 index 0000000..3ddfb2c --- /dev/null +++ b/Ahmad/2_puzzles/assignment_05/.project @@ -0,0 +1,17 @@ + + + assignment_05 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + 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/2_puzzles/assignment_05/.settings/org.eclipse.jdt.core.prefs b/Ahmad/2_puzzles/assignment_05/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..8c9943d --- /dev/null +++ b/Ahmad/2_puzzles/assignment_05/.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_05/src/assignment_05/App.java b/Ahmad/2_puzzles/assignment_05/src/assignment_05/App.java new file mode 100644 index 0000000..361f3b3 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_05/src/assignment_05/App.java @@ -0,0 +1,54 @@ +package assignment_05; + +import ignore.TestingUtils; + +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, + second does not need to be greater than first but still better be less than third. +
+
+ + * EXPECTATIONS:
+ isOrdered(1, 2, 4, false) ---> true
+ isOrdered(1, 2, 1, false) ---> false
+ isOrdered(1, 1, 2, true) ---> true
+ */ + public static boolean isOrdered(int first, int second, int third, boolean itsOk) { + + boolean value = (itsOk) ? (second < third) : (second > first && third > second); + +// boolean ordered = false; +// +// if(!itsOk && second > first && third > second) { +// ordered = true; +// } +// if(itsOk && second < third) { +// ordered = true; +// } + + + return value; + } + + + + + + + + + + + + //----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// + public static void main(String args[]){ + TestingUtils.runTests(); + } +} + + diff --git a/Ahmad/2_puzzles/assignment_05/src/ignore/TestingUtils.java b/Ahmad/2_puzzles/assignment_05/src/ignore/TestingUtils.java new file mode 100644 index 0000000..b5185ec --- /dev/null +++ b/Ahmad/2_puzzles/assignment_05/src/ignore/TestingUtils.java @@ -0,0 +1,41 @@ +package ignore; + +import assignment_05.App; + +public class TestingUtils { + public static void runTests(){ + + + int[] params1 = { 1, 1, 1, 3, 2, 3, 4, 4, 2, 7, 7, 7 }; + + int[] params2 = { 2, 2, 1, 2, 3, 2, 2, 5, 4, 9, 5, 5 }; + + int[] params3 = { 4, 1, 2, 4, 4, 4, 2, 2, 6, 10, 6, 4 }; + + boolean[] params4 = { false, false, true, false, false, true, true, true, true, false, true, true }; + + boolean[] expected = { true, false, true, false, true, true, false, false, true, true, true, false }; + + for(int i=0; i < params1.length; i++){ + boolean result = App.isOrdered(params1[i], params2[i], params3[i], params4[i]); + if(result == expected[i]) { + System.out.println(printPassResult(params1[i], params2[i],params3[i], params4[i], expected[i], result)); + } else{ + System.out.println(printFailResult(params1[i], params2[i], params3[i], params4[i], expected[i], result)); + } + } + } + + private static String printPassResult(Object params1, Object params2, Object params3, Object params4, Object expected, Object result){ + return "PASS: isOrdered("+ params1.toString()+ ", "+ params2.toString()+", "+ params3.toString()+", "+ params4.toString()+ ") -> " + result.toString(); + } + + + private static String printFailResult(Object params1, Object params2, Object params3, Object params4, Object expected, Object result){ + String ret = "**********************" + "\n"; + ret += "FAIL: isOrdered("+ params1.toString()+ ", "+ params2.toString()+", "+ params3.toString()+", "+ params4.toString()+ ") -> " + result.toString() + + " Expected: "+ expected.toString(); + ret += "\n" + "**********************"; + return ret; + } +} \ No newline at end of file From 3f045d158c49e5c247e95850347ff73802b25c9e Mon Sep 17 00:00:00 2001 From: possibilitiesInTest Date: Wed, 28 Feb 2024 09:48:51 -0500 Subject: [PATCH 08/14] isCool, fizzBuzz, sumUnique, nearestTwentyOne, partialSum --- Ahmad/2_puzzles/assignment_06/.classpath | 10 ++++ Ahmad/2_puzzles/assignment_06/.gitignore | 1 + Ahmad/2_puzzles/assignment_06/.project | 17 ++++++ .../org.eclipse.core.resources.prefs | 2 + .../.settings/org.eclipse.jdt.core.prefs | 14 +++++ .../assignment_06/src/assignment_06/App.java | 49 +++++++++++++++ .../src/ignore/TestingUtils.java | 35 +++++++++++ Ahmad/2_puzzles/assignment_07/.classpath | 10 ++++ Ahmad/2_puzzles/assignment_07/.gitignore | 1 + Ahmad/2_puzzles/assignment_07/.project | 17 ++++++ .../org.eclipse.core.resources.prefs | 2 + .../.settings/org.eclipse.jdt.core.prefs | 14 +++++ .../assignment_07/src/assignment_07/App.java | 53 ++++++++++++++++ .../src/ignore/TestingUtils.java | 35 +++++++++++ Ahmad/2_puzzles/assignment_08/.classpath | 10 ++++ Ahmad/2_puzzles/assignment_08/.gitignore | 1 + Ahmad/2_puzzles/assignment_08/.project | 17 ++++++ .../org.eclipse.core.resources.prefs | 2 + .../.settings/org.eclipse.jdt.core.prefs | 14 +++++ .../assignment_08/src/assignment_08/App.java | 50 ++++++++++++++++ .../src/ignore/TestingUtils.java | 39 ++++++++++++ Ahmad/2_puzzles/assignment_09/.classpath | 10 ++++ Ahmad/2_puzzles/assignment_09/.gitignore | 1 + Ahmad/2_puzzles/assignment_09/.project | 17 ++++++ .../org.eclipse.core.resources.prefs | 2 + .../.settings/org.eclipse.jdt.core.prefs | 14 +++++ .../assignment_09/src/assignment_09/App.java | 50 ++++++++++++++++ .../src/ignore/TestingUtils.java | 37 ++++++++++++ Ahmad/2_puzzles/assignment_10/.classpath | 10 ++++ Ahmad/2_puzzles/assignment_10/.gitignore | 1 + Ahmad/2_puzzles/assignment_10/.project | 17 ++++++ .../org.eclipse.core.resources.prefs | 2 + .../.settings/org.eclipse.jdt.core.prefs | 14 +++++ .../assignment_10/src/assignment_10/App.java | 60 +++++++++++++++++++ .../src/ignore/TestingUtils.java | 38 ++++++++++++ 35 files changed, 666 insertions(+) create mode 100644 Ahmad/2_puzzles/assignment_06/.classpath create mode 100644 Ahmad/2_puzzles/assignment_06/.gitignore create mode 100644 Ahmad/2_puzzles/assignment_06/.project create mode 100644 Ahmad/2_puzzles/assignment_06/.settings/org.eclipse.core.resources.prefs create mode 100644 Ahmad/2_puzzles/assignment_06/.settings/org.eclipse.jdt.core.prefs create mode 100644 Ahmad/2_puzzles/assignment_06/src/assignment_06/App.java create mode 100644 Ahmad/2_puzzles/assignment_06/src/ignore/TestingUtils.java create mode 100644 Ahmad/2_puzzles/assignment_07/.classpath create mode 100644 Ahmad/2_puzzles/assignment_07/.gitignore create mode 100644 Ahmad/2_puzzles/assignment_07/.project create mode 100644 Ahmad/2_puzzles/assignment_07/.settings/org.eclipse.core.resources.prefs create mode 100644 Ahmad/2_puzzles/assignment_07/.settings/org.eclipse.jdt.core.prefs create mode 100644 Ahmad/2_puzzles/assignment_07/src/assignment_07/App.java create mode 100644 Ahmad/2_puzzles/assignment_07/src/ignore/TestingUtils.java create mode 100644 Ahmad/2_puzzles/assignment_08/.classpath create mode 100644 Ahmad/2_puzzles/assignment_08/.gitignore create mode 100644 Ahmad/2_puzzles/assignment_08/.project create mode 100644 Ahmad/2_puzzles/assignment_08/.settings/org.eclipse.core.resources.prefs create mode 100644 Ahmad/2_puzzles/assignment_08/.settings/org.eclipse.jdt.core.prefs create mode 100644 Ahmad/2_puzzles/assignment_08/src/assignment_08/App.java create mode 100644 Ahmad/2_puzzles/assignment_08/src/ignore/TestingUtils.java create mode 100644 Ahmad/2_puzzles/assignment_09/.classpath create mode 100644 Ahmad/2_puzzles/assignment_09/.gitignore create mode 100644 Ahmad/2_puzzles/assignment_09/.project create mode 100644 Ahmad/2_puzzles/assignment_09/.settings/org.eclipse.core.resources.prefs create mode 100644 Ahmad/2_puzzles/assignment_09/.settings/org.eclipse.jdt.core.prefs create mode 100644 Ahmad/2_puzzles/assignment_09/src/assignment_09/App.java create mode 100644 Ahmad/2_puzzles/assignment_09/src/ignore/TestingUtils.java create mode 100644 Ahmad/2_puzzles/assignment_10/.classpath create mode 100644 Ahmad/2_puzzles/assignment_10/.gitignore create mode 100644 Ahmad/2_puzzles/assignment_10/.project create mode 100644 Ahmad/2_puzzles/assignment_10/.settings/org.eclipse.core.resources.prefs create mode 100644 Ahmad/2_puzzles/assignment_10/.settings/org.eclipse.jdt.core.prefs create mode 100644 Ahmad/2_puzzles/assignment_10/src/assignment_10/App.java create mode 100644 Ahmad/2_puzzles/assignment_10/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/2_puzzles/assignment_06/.gitignore b/Ahmad/2_puzzles/assignment_06/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_06/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/2_puzzles/assignment_06/.project b/Ahmad/2_puzzles/assignment_06/.project new file mode 100644 index 0000000..97391bf --- /dev/null +++ b/Ahmad/2_puzzles/assignment_06/.project @@ -0,0 +1,17 @@ + + + assignment_06 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + 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/2_puzzles/assignment_06/src/assignment_06/App.java b/Ahmad/2_puzzles/assignment_06/src/assignment_06/App.java new file mode 100644 index 0000000..60008f4 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_06/src/assignment_06/App.java @@ -0,0 +1,49 @@ +package assignment_06; + +import ignore.TestingUtils; + +public class App { + + /** + We'll say a number is cool if it's a multiple of 11 or if it is one more than a multiple of 11. + Return true if the given non-negative number is cool. Use the % "modulus" operator + we spoke about in the prerequisite section. Watch the lesson on modulus if you need to review +
+
+ + * EXPECTATIONS:
+ isCool(22) ---> true
+ isCool(23) ---> true
+ isCool(24) ---> false
+ */ + public static boolean isCool(int n) { + + boolean cool = false; + + if(n % 11 == 0 || n % 11 == 1) { + cool = true; + } + + + return cool; + } + + + + + + + + + + + + + //----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// + public static void main(String args[]){ + TestingUtils.runTests(); + + } +} + + diff --git a/Ahmad/2_puzzles/assignment_06/src/ignore/TestingUtils.java b/Ahmad/2_puzzles/assignment_06/src/ignore/TestingUtils.java new file mode 100644 index 0000000..63f9a10 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_06/src/ignore/TestingUtils.java @@ -0,0 +1,35 @@ +package ignore; + +import assignment_06.App; + +public class TestingUtils { + public static void runTests(){ + + + int[] params1 = { 22, 23, 24, 21, 11, 12, 10, 9, 8, 0, 1, 2, 121, 122, 123, 46, 49, 52, 54, 55 }; + boolean[] expected = { true, true, false, false, true, true, false, false, false, true, true, false, true, true, + false, false, false, false, false, true }; + + for(int i=0; i < params1.length; i++){ + boolean result = App.isCool(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: isCool("+ params1.toString()+ ") -> " + result.toString(); + } + + + private static String printFailResult(Object params1, Object expected, Object result){ + String ret = "**********************" + "\n"; + ret += "FAIL: isCool("+ params1.toString()+ ") -> " + result.toString() + + " Expected: "+ expected.toString(); + ret += "\n" + "**********************"; + return ret; + } +} \ No newline at end of file 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/2_puzzles/assignment_07/.gitignore b/Ahmad/2_puzzles/assignment_07/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_07/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/2_puzzles/assignment_07/.project b/Ahmad/2_puzzles/assignment_07/.project new file mode 100644 index 0000000..75ef8a6 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_07/.project @@ -0,0 +1,17 @@ + + + assignment_07 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + 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/2_puzzles/assignment_07/src/assignment_07/App.java b/Ahmad/2_puzzles/assignment_07/src/assignment_07/App.java new file mode 100644 index 0000000..9fb4781 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_07/src/assignment_07/App.java @@ -0,0 +1,53 @@ +package assignment_07; + +import ignore.TestingUtils; + +public class App { + + /** + Given an int n, return the string form of the number followed by "!". + So if the int is for example 13 this method should return "13!". + However the catch is that if the number is divisible by 3 the method should return "Fizz!" + instead of the number, and if the number is divisible by 5 it should return "Buzz!", + and if divisible by both 3 and 5, use "FizzBuzz!". You’ll need to use the % "mod" + for computing the remainder after division, so 23 % 10 yields 3. + +
+
+ + * EXPECTATIONS:
+ fizzyWizzy(1) ---> "1!"
+ fizzyWizzy(2) ---> "2!"
+ fizzyWizzy(3) ---> "Fizz!"
+ */ + public static String fizzyWizzy(int n) { + + boolean fizz = n % 3 == 0; + boolean buzz = n % 5 ==0; + + if(fizz & buzz) return "FizzBuzz!"; + if(fizz) return "Fizz!"; + if(buzz) return "Buzz!"; + + + } + + + + + + + + + + + + + //----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// + public static void main(String args[]){ + TestingUtils.runTests(); + + } +} + + diff --git a/Ahmad/2_puzzles/assignment_07/src/ignore/TestingUtils.java b/Ahmad/2_puzzles/assignment_07/src/ignore/TestingUtils.java new file mode 100644 index 0000000..e91cf46 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_07/src/ignore/TestingUtils.java @@ -0,0 +1,35 @@ +package ignore; + +import assignment_07.App; + +public class TestingUtils { + public static void runTests(){ + + + int[] params1 = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 15, 16, 18, 19, 21, 44, 45, 100 }; + String[] expected = { "1!", "2!", "Fizz!", "4!", "Buzz!", "Fizz!", "7!", "8!", "Fizz!", "FizzBuzz!", "16!", + "Fizz!", "19!", "Fizz!", "44!", "FizzBuzz!", "Buzz!" }; + + for(int i=0; i < params1.length; i++){ + String result = App.fizzyWizzy(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: fizzyWizzy("+ params1.toString()+ ") -> " + result.toString(); + } + + + private static String printFailResult(Object params1, Object expected, Object result){ + String ret = "**********************" + "\n"; + ret += "FAIL: fizzyWizzy("+ params1.toString()+ ") -> " + result.toString() + + " Expected: "+ expected.toString(); + ret += "\n" + "**********************"; + return ret; + } +} \ No newline at end of file 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/2_puzzles/assignment_08/.gitignore b/Ahmad/2_puzzles/assignment_08/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_08/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/2_puzzles/assignment_08/.project b/Ahmad/2_puzzles/assignment_08/.project new file mode 100644 index 0000000..1d1e6db --- /dev/null +++ b/Ahmad/2_puzzles/assignment_08/.project @@ -0,0 +1,17 @@ + + + assignment_08 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + 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/2_puzzles/assignment_08/src/assignment_08/App.java b/Ahmad/2_puzzles/assignment_08/src/assignment_08/App.java new file mode 100644 index 0000000..1df95b6 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_08/src/assignment_08/App.java @@ -0,0 +1,50 @@ +package assignment_08; + +import ignore.TestingUtils; + +public class App { + + + /** + + Given 3 int arguments - a, b, c, return their sum. However, if one of the arguments + is the same as any of the other ones, that number should not count towards the sum. + So basically you only sum unique numbers, not duplicates +
+
+ + * EXPECTATIONS:
+ sumUnique(1, 2, 3) ---> 6
+ sumUnique(3, 2, 3) ---> 2
+ sumUnique(3, 3, 3) ---> 0
+ */ + + public static int sumUnique(int a, int b, int c) { + + + 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; + + } + + + + + + + + + + + + //----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// + public static void main(String args[]){ + TestingUtils.runTests(); + + } +} diff --git a/Ahmad/2_puzzles/assignment_08/src/ignore/TestingUtils.java b/Ahmad/2_puzzles/assignment_08/src/ignore/TestingUtils.java new file mode 100644 index 0000000..9d3ecbe --- /dev/null +++ b/Ahmad/2_puzzles/assignment_08/src/ignore/TestingUtils.java @@ -0,0 +1,39 @@ +package ignore; + +import assignment_08.App; + +public class TestingUtils { + public static void runTests(){ + + + int[] params1 = { 1, 3, 3, 9, 2, 2, 2, 4, 1 }; + + int[] params2 = { 2, 2, 3, 2, 2, 9, 9, 2, 3 }; + + int[] params3 = { 3, 3, 3, 2, 9, 2, 3, 3, 1 }; + + int[] expected = { 6, 2, 0, 9, 9, 9, 14, 9, 3 }; + + for(int i=0; i < params1.length; i++){ + int result = App.sumUnique(params1[i], params2[i], params3[i]); + if(result == expected[i]) { + System.out.println(printPassResult(params1[i], params2[i], params3[i], expected[i], result)); + } else{ + System.out.println(printFailResult(params1[i], params2[i], params3[i], expected[i], result)); + } + } + } + + private static String printPassResult(Object params1, Object params2, Object params3, Object expected, Object result){ + return "PASS: sumUnique("+ params1.toString()+ ", "+ params2.toString()+ ", "+ params3.toString()+ ") -> " + result.toString(); + } + + + private static String printFailResult(Object params1, Object params2, Object params3, Object expected, Object result){ + String ret = "**********************" + "\n"; + ret += "FAIL: sumUnique("+ params1.toString()+ ", "+ params2.toString()+", "+ params3.toString()+ ") -> " + result.toString() + + " Expected: "+ expected.toString(); + ret += "\n" + "**********************"; + return ret; + } +} \ No newline at end of file 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/2_puzzles/assignment_09/.gitignore b/Ahmad/2_puzzles/assignment_09/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_09/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/2_puzzles/assignment_09/.project b/Ahmad/2_puzzles/assignment_09/.project new file mode 100644 index 0000000..41d732d --- /dev/null +++ b/Ahmad/2_puzzles/assignment_09/.project @@ -0,0 +1,17 @@ + + + assignment_09 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + 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/2_puzzles/assignment_09/src/assignment_09/App.java b/Ahmad/2_puzzles/assignment_09/src/assignment_09/App.java new file mode 100644 index 0000000..2a9b52e --- /dev/null +++ b/Ahmad/2_puzzles/assignment_09/src/assignment_09/App.java @@ -0,0 +1,50 @@ +package assignment_09; + +import ignore.TestingUtils; + +public class App { + + + /** + + Given 2 positive int arguments (a, b), return whichever argument is + nearest to the number 21 without going over. + Return 0 if they both go over 21. +
+
+ + * EXPECTATIONS:
+ nearestTwentyOne(19, 21) ---> 21
+ nearestTwentyOne(21, 19) ---> 21
+ nearestTwentyOne(19, 22) ---> 19
+ nearestTwentyOne(32, 22) ---> 0
+ */ + + public static int nearestTwentyOne(int a, int 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 + return b; + } + + + + + + + + + + + + //----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// + public static void main(String args[]){ + TestingUtils.runTests(); + + } +} diff --git a/Ahmad/2_puzzles/assignment_09/src/ignore/TestingUtils.java b/Ahmad/2_puzzles/assignment_09/src/ignore/TestingUtils.java new file mode 100644 index 0000000..9123745 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_09/src/ignore/TestingUtils.java @@ -0,0 +1,37 @@ +package ignore; + +import assignment_09.App; + +public class TestingUtils { + public static void runTests(){ + + + int[] params1 = { 19, 21, 19, 22, 22, 22, 33, 1, 34, 17, 18, 16, 3, 3, 21 }; + + int[] params2 = { 21, 19, 22, 19, 50, 22, 1, 2, 33, 19, 17, 23, 4, 2, 20 }; + + int[] expected = { 21, 21, 19, 19, 0, 0, 1, 2, 0, 19, 18, 16, 4, 3, 21 }; + + for(int i=0; i < params1.length; i++){ + int result = App.nearestTwentyOne(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: nearestTwentyOne("+ params1.toString()+ ", "+ params2.toString()+ ") -> " + result.toString(); + } + + + private static String printFailResult(Object params1, Object params2, Object expected, Object result){ + String ret = "**********************" + "\n"; + ret += "FAIL: nearestTwentyOne("+ params1.toString()+ ", "+ params2.toString()+ ") -> " + result.toString() + + " Expected: "+ expected.toString(); + ret += "\n" + "**********************"; + return ret; + } +} \ No newline at end of file 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/2_puzzles/assignment_10/.gitignore b/Ahmad/2_puzzles/assignment_10/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_10/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/2_puzzles/assignment_10/.project b/Ahmad/2_puzzles/assignment_10/.project new file mode 100644 index 0000000..b1f6869 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_10/.project @@ -0,0 +1,17 @@ + + + assignment_10 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + 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/2_puzzles/assignment_10/src/assignment_10/App.java b/Ahmad/2_puzzles/assignment_10/src/assignment_10/App.java new file mode 100644 index 0000000..96df596 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_10/src/assignment_10/App.java @@ -0,0 +1,60 @@ +package assignment_10; + +import ignore.TestingUtils; + +public class App { + + + /** + + Given 3 int arguments, a b c, return their sum. However, if one of the arguments is 13 + then it does not count towards the sum and arguments to it's right do not count either. + So for example, if b is 13, then both b and c do not count. +
+
+ + * EXPECTATIONS:
+ partialSum(1, 2, 3) ---> 6
+ partialSum(1, 2, 13) ---> 3
+ partialSum(1, 13, 3) ---> 1
+ */ + + public static int partialSum(int a, int b, int c) { + +// 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; + + return a + b + c; + + } + + + + + + + + + + + + //----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// + public static void main(String args[]){ + TestingUtils.runTests(); + + } +} diff --git a/Ahmad/2_puzzles/assignment_10/src/ignore/TestingUtils.java b/Ahmad/2_puzzles/assignment_10/src/ignore/TestingUtils.java new file mode 100644 index 0000000..6bfb20b --- /dev/null +++ b/Ahmad/2_puzzles/assignment_10/src/ignore/TestingUtils.java @@ -0,0 +1,38 @@ +package ignore; + +import assignment_10.App; + +public class TestingUtils { + public static void runTests(){ + + int[] params1 = { 1, 1, 1, 1, 6, 13, 13, 13, 9, 8, 7, 3 }; + + int[] params2 = { 2, 2, 13, 13, 5, 2, 2, 13, 4, 13, 2, 3 }; + + int[] params3 = { 3, 13, 3, 13, 2, 3, 13, 2, 13, 2, 1, 13 }; + + int[] expected = { 6, 3, 1, 1, 13, 0, 0, 0, 13, 8, 10, 6 }; + + for(int i=0; i < params1.length; i++){ + int result = App.partialSum(params1[i], params2[i], params3[i]); + if(result == expected[i]) { + System.out.println(printPassResult(params1[i], params2[i], params3[i], expected[i], result)); + } else{ + System.out.println(printFailResult(params1[i], params2[i], params3[i], expected[i], result)); + } + } + } + + private static String printPassResult(Object params1, Object params2, Object params3, Object expected, Object result){ + return "PASS: partialSum("+ params1.toString()+ ", "+ params2.toString()+ ", "+ params3.toString()+ ") -> " + result.toString(); + } + + + private static String printFailResult(Object params1, Object params2, Object params3, Object expected, Object result){ + String ret = "**********************" + "\n"; + ret += "FAIL: partialSum("+ params1.toString()+ ", "+ params2.toString()+", "+ params3.toString()+ ") -> " + result.toString() + + " Expected: "+ expected.toString(); + ret += "\n" + "**********************"; + return ret; + } +} \ No newline at end of file From 031ce8599d675cdef152bbaf0e90036eb6c12e03 Mon Sep 17 00:00:00 2001 From: possibilitiesInTest Date: Wed, 28 Feb 2024 11:47:17 -0500 Subject: [PATCH 09/14] update saved files --- Ahmad/2_puzzles/assignment_06/src/assignment_06/App.java | 1 - Ahmad/2_puzzles/assignment_08/src/assignment_08/App.java | 2 -- 2 files changed, 3 deletions(-) diff --git a/Ahmad/2_puzzles/assignment_06/src/assignment_06/App.java b/Ahmad/2_puzzles/assignment_06/src/assignment_06/App.java index 60008f4..5ab7e6d 100644 --- a/Ahmad/2_puzzles/assignment_06/src/assignment_06/App.java +++ b/Ahmad/2_puzzles/assignment_06/src/assignment_06/App.java @@ -24,7 +24,6 @@ public static boolean isCool(int n) { cool = true; } - return cool; } diff --git a/Ahmad/2_puzzles/assignment_08/src/assignment_08/App.java b/Ahmad/2_puzzles/assignment_08/src/assignment_08/App.java index 1df95b6..f923aab 100644 --- a/Ahmad/2_puzzles/assignment_08/src/assignment_08/App.java +++ b/Ahmad/2_puzzles/assignment_08/src/assignment_08/App.java @@ -21,13 +21,11 @@ public class App { public static int sumUnique(int a, int b, int c) { - 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; } From 13198906c49082c3ea11b7016ccfab45f7f9468c Mon Sep 17 00:00:00 2001 From: possibilitiesInTest Date: Sat, 2 Mar 2024 11:14:27 -0500 Subject: [PATCH 10/14] repeatChar, starKill, wordsCount, matchingChar, longestStreak solutions: matchingChar: -set count -iterate through a -set str1, str2 to a[i], b[i] -check if str1,str2 are empty -check if charAt(0) are equal -increment, return count longestStreak -set max -iterate i -set count -iterate j -check if charAt(i) equals charAt(j) -increment count -else break -if count greater than max: update max -return max --- .../assignment_07/src/assignment_07/App.java | 2 +- Ahmad/2_puzzles/assignment_11/.classpath | 10 ++++ Ahmad/2_puzzles/assignment_11/.gitignore | 1 + Ahmad/2_puzzles/assignment_11/.project | 17 ++++++ .../org.eclipse.core.resources.prefs | 2 + .../.settings/org.eclipse.jdt.core.prefs | 14 +++++ .../assignment_11/src/assignment_11/App.java | 46 ++++++++++++++ .../src/ignore/TestingUtils.java | 34 +++++++++++ Ahmad/2_puzzles/assignment_12/.classpath | 10 ++++ Ahmad/2_puzzles/assignment_12/.gitignore | 1 + Ahmad/2_puzzles/assignment_12/.project | 17 ++++++ .../org.eclipse.core.resources.prefs | 2 + .../.settings/org.eclipse.jdt.core.prefs | 14 +++++ .../assignment_12/src/assignment_12/App.java | 60 +++++++++++++++++++ .../src/ignore/TestingUtils.java | 36 +++++++++++ Ahmad/2_puzzles/assignment_13/.classpath | 10 ++++ Ahmad/2_puzzles/assignment_13/.gitignore | 1 + Ahmad/2_puzzles/assignment_13/.project | 17 ++++++ .../org.eclipse.core.resources.prefs | 2 + .../.settings/org.eclipse.jdt.core.prefs | 14 +++++ .../assignment_13/src/assignment_13/App.java | 47 +++++++++++++++ .../src/ignore/TestingUtils.java | 41 +++++++++++++ Ahmad/2_puzzles/assignment_14/.classpath | 10 ++++ Ahmad/2_puzzles/assignment_14/.gitignore | 1 + Ahmad/2_puzzles/assignment_14/.project | 17 ++++++ .../org.eclipse.core.resources.prefs | 2 + .../.settings/org.eclipse.jdt.core.prefs | 14 +++++ .../assignment_14/src/assignment_14/App.java | 56 +++++++++++++++++ .../src/ignore/TestingUtils.java | 45 ++++++++++++++ Ahmad/2_puzzles/assignment_15/.classpath | 10 ++++ Ahmad/2_puzzles/assignment_15/.gitignore | 1 + Ahmad/2_puzzles/assignment_15/.project | 17 ++++++ .../org.eclipse.core.resources.prefs | 2 + .../.settings/org.eclipse.jdt.core.prefs | 14 +++++ .../assignment_15/src/assignment_15/App.java | 59 ++++++++++++++++++ .../src/ignore/TestingUtils.java | 36 +++++++++++ 36 files changed, 681 insertions(+), 1 deletion(-) create mode 100644 Ahmad/2_puzzles/assignment_11/.classpath create mode 100644 Ahmad/2_puzzles/assignment_11/.gitignore create mode 100644 Ahmad/2_puzzles/assignment_11/.project create mode 100644 Ahmad/2_puzzles/assignment_11/.settings/org.eclipse.core.resources.prefs create mode 100644 Ahmad/2_puzzles/assignment_11/.settings/org.eclipse.jdt.core.prefs create mode 100644 Ahmad/2_puzzles/assignment_11/src/assignment_11/App.java create mode 100644 Ahmad/2_puzzles/assignment_11/src/ignore/TestingUtils.java create mode 100644 Ahmad/2_puzzles/assignment_12/.classpath create mode 100644 Ahmad/2_puzzles/assignment_12/.gitignore create mode 100644 Ahmad/2_puzzles/assignment_12/.project create mode 100644 Ahmad/2_puzzles/assignment_12/.settings/org.eclipse.core.resources.prefs create mode 100644 Ahmad/2_puzzles/assignment_12/.settings/org.eclipse.jdt.core.prefs create mode 100644 Ahmad/2_puzzles/assignment_12/src/assignment_12/App.java create mode 100644 Ahmad/2_puzzles/assignment_12/src/ignore/TestingUtils.java create mode 100644 Ahmad/2_puzzles/assignment_13/.classpath create mode 100644 Ahmad/2_puzzles/assignment_13/.gitignore create mode 100644 Ahmad/2_puzzles/assignment_13/.project create mode 100644 Ahmad/2_puzzles/assignment_13/.settings/org.eclipse.core.resources.prefs create mode 100644 Ahmad/2_puzzles/assignment_13/.settings/org.eclipse.jdt.core.prefs create mode 100644 Ahmad/2_puzzles/assignment_13/src/assignment_13/App.java create mode 100644 Ahmad/2_puzzles/assignment_13/src/ignore/TestingUtils.java create mode 100644 Ahmad/2_puzzles/assignment_14/.classpath create mode 100644 Ahmad/2_puzzles/assignment_14/.gitignore create mode 100644 Ahmad/2_puzzles/assignment_14/.project create mode 100644 Ahmad/2_puzzles/assignment_14/.settings/org.eclipse.core.resources.prefs create mode 100644 Ahmad/2_puzzles/assignment_14/.settings/org.eclipse.jdt.core.prefs create mode 100644 Ahmad/2_puzzles/assignment_14/src/assignment_14/App.java create mode 100644 Ahmad/2_puzzles/assignment_14/src/ignore/TestingUtils.java create mode 100644 Ahmad/2_puzzles/assignment_15/.classpath create mode 100644 Ahmad/2_puzzles/assignment_15/.gitignore create mode 100644 Ahmad/2_puzzles/assignment_15/.project create mode 100644 Ahmad/2_puzzles/assignment_15/.settings/org.eclipse.core.resources.prefs create mode 100644 Ahmad/2_puzzles/assignment_15/.settings/org.eclipse.jdt.core.prefs create mode 100644 Ahmad/2_puzzles/assignment_15/src/assignment_15/App.java create mode 100644 Ahmad/2_puzzles/assignment_15/src/ignore/TestingUtils.java diff --git a/Ahmad/2_puzzles/assignment_07/src/assignment_07/App.java b/Ahmad/2_puzzles/assignment_07/src/assignment_07/App.java index 9fb4781..d76c8fa 100644 --- a/Ahmad/2_puzzles/assignment_07/src/assignment_07/App.java +++ b/Ahmad/2_puzzles/assignment_07/src/assignment_07/App.java @@ -29,7 +29,7 @@ public static String fizzyWizzy(int n) { if(fizz) return "Fizz!"; if(buzz) return "Buzz!"; - + return n + "!"; } 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/2_puzzles/assignment_11/.gitignore b/Ahmad/2_puzzles/assignment_11/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_11/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/2_puzzles/assignment_11/.project b/Ahmad/2_puzzles/assignment_11/.project new file mode 100644 index 0000000..7eb9a73 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_11/.project @@ -0,0 +1,17 @@ + + + assignment_11 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + 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(); + } + + + private static String printFailResult(Object params1, Object expected, Object result){ + String ret = "**********************" + "\n"; + ret += "FAIL: repeatChar("+ params1.toString()+") -> " + result.toString() + + " Expected: "+ expected.toString(); + ret += "\n" + "**********************"; + return ret; + } +} \ No newline at end of file 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/2_puzzles/assignment_12/.gitignore b/Ahmad/2_puzzles/assignment_12/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_12/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/2_puzzles/assignment_12/.project b/Ahmad/2_puzzles/assignment_12/.project new file mode 100644 index 0000000..c5b011e --- /dev/null +++ b/Ahmad/2_puzzles/assignment_12/.project @@ -0,0 +1,17 @@ + + + assignment_12 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + 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/2_puzzles/assignment_13/.project b/Ahmad/2_puzzles/assignment_13/.project new file mode 100644 index 0000000..46bb0f6 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_13/.project @@ -0,0 +1,17 @@ + + + assignment_13 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + 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 From 4ae773e18b253dd3161be855714c3fded2be11f2 Mon Sep 17 00:00:00 2001 From: possibilitiesInTest Date: Sat, 2 Mar 2024 20:39:30 -0500 Subject: [PATCH 11/14] yoYo solution: -if str length less than two: return zero -if substring of 0,2 equals yo: -return 1 plus yoYo of substring at 1 -else -return yoYo at substring 1 --- Ahmad/2_puzzles/assignment_16/.classpath | 10 ++++ Ahmad/2_puzzles/assignment_16/.gitignore | 1 + Ahmad/2_puzzles/assignment_16/.project | 17 ++++++ .../org.eclipse.core.resources.prefs | 2 + .../.settings/org.eclipse.jdt.core.prefs | 14 +++++ .../assignment_16/src/assignment_16/App.java | 60 +++++++++++++++++++ .../src/ignore/TestingUtils.java | 36 +++++++++++ 7 files changed, 140 insertions(+) create mode 100644 Ahmad/2_puzzles/assignment_16/.classpath create mode 100644 Ahmad/2_puzzles/assignment_16/.gitignore create mode 100644 Ahmad/2_puzzles/assignment_16/.project create mode 100644 Ahmad/2_puzzles/assignment_16/.settings/org.eclipse.core.resources.prefs create mode 100644 Ahmad/2_puzzles/assignment_16/.settings/org.eclipse.jdt.core.prefs create mode 100644 Ahmad/2_puzzles/assignment_16/src/assignment_16/App.java create mode 100644 Ahmad/2_puzzles/assignment_16/src/ignore/TestingUtils.java 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 From 3c2effca182dfea2451317e1a68f4203094d7c14 Mon Sep 17 00:00:00 2001 From: possibilitiesInTest Date: Sat, 2 Mar 2024 20:46:15 -0500 Subject: [PATCH 12/14] endoo solution: -if str.equals empty: return str -if str.charAt zero equals o -return endoo of substring at 1 plus o -else -return charAt zero plus endoo of substring at one --- Ahmad/2_puzzles/assignment_17/.classpath | 10 ++++ Ahmad/2_puzzles/assignment_17/.gitignore | 1 + Ahmad/2_puzzles/assignment_17/.project | 17 ++++++ .../org.eclipse.core.resources.prefs | 2 + .../.settings/org.eclipse.jdt.core.prefs | 14 +++++ .../assignment_17/src/assignment_17/App.java | 55 +++++++++++++++++++ .../src/ignore/TestingUtils.java | 37 +++++++++++++ 7 files changed, 136 insertions(+) create mode 100644 Ahmad/2_puzzles/assignment_17/.classpath create mode 100644 Ahmad/2_puzzles/assignment_17/.gitignore create mode 100644 Ahmad/2_puzzles/assignment_17/.project create mode 100644 Ahmad/2_puzzles/assignment_17/.settings/org.eclipse.core.resources.prefs create mode 100644 Ahmad/2_puzzles/assignment_17/.settings/org.eclipse.jdt.core.prefs create mode 100644 Ahmad/2_puzzles/assignment_17/src/assignment_17/App.java create mode 100644 Ahmad/2_puzzles/assignment_17/src/ignore/TestingUtils.java 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 From 77a0823d98250640f41235814eb66cbb2f860c8e Mon Sep 17 00:00:00 2001 From: possibilitiesInTest Date: Sat, 2 Mar 2024 22:42:41 -0500 Subject: [PATCH 13/14] hyphenSplit solution: if str len less than two: return str -if charAt zero equals charAt one -return charAt zero - hyphenSplit substring at one -return charAt zero plus hyphSplit substring at one --- Ahmad/2_puzzles/assignment_18/.classpath | 10 ++++ Ahmad/2_puzzles/assignment_18/.gitignore | 1 + Ahmad/2_puzzles/assignment_18/.project | 17 ++++++ .../org.eclipse.core.resources.prefs | 2 + .../.settings/org.eclipse.jdt.core.prefs | 14 +++++ .../assignment_18/src/assignment_18/App.java | 55 +++++++++++++++++++ .../src/ignore/TestingUtils.java | 37 +++++++++++++ 7 files changed, 136 insertions(+) create mode 100644 Ahmad/2_puzzles/assignment_18/.classpath create mode 100644 Ahmad/2_puzzles/assignment_18/.gitignore create mode 100644 Ahmad/2_puzzles/assignment_18/.project create mode 100644 Ahmad/2_puzzles/assignment_18/.settings/org.eclipse.core.resources.prefs create mode 100644 Ahmad/2_puzzles/assignment_18/.settings/org.eclipse.jdt.core.prefs create mode 100644 Ahmad/2_puzzles/assignment_18/src/assignment_18/App.java create mode 100644 Ahmad/2_puzzles/assignment_18/src/ignore/TestingUtils.java 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 From 77b38c33496d183b8ae008cdad5e467361a3178d Mon Sep 17 00:00:00 2001 From: possibilitiesInTest Date: Sun, 3 Mar 2024 10:00:34 -0500 Subject: [PATCH 14/14] insideBrackets solution: -if charAt zero does not equal open brace -return iB at substring 1 -if charAt length minus one does not equal close brace -return iB substring zero to len minus one -return str --- Ahmad/2_puzzles/assignment_19/.classpath | 10 ++++ Ahmad/2_puzzles/assignment_19/.gitignore | 1 + Ahmad/2_puzzles/assignment_19/.project | 17 ++++++ .../org.eclipse.core.resources.prefs | 2 + .../.settings/org.eclipse.jdt.core.prefs | 14 +++++ .../assignment_19/src/assignment_19/App.java | 53 +++++++++++++++++++ .../src/ignore/TestingUtils.java | 38 +++++++++++++ Ahmad/2_puzzles/assignment_n/.classpath | 10 ++++ Ahmad/2_puzzles/assignment_n/.gitignore | 1 + Ahmad/2_puzzles/assignment_n/.project | 17 ++++++ .../org.eclipse.core.resources.prefs | 2 + .../.settings/org.eclipse.jdt.core.prefs | 14 +++++ .../assignment_n/src/assignment_n/App.java | 34 ++++++++++++ .../assignment_n/src/ignore/TestingUtils.java | 37 +++++++++++++ .../assignment_n/src/module-info.java | 8 +++ 15 files changed, 258 insertions(+) create mode 100644 Ahmad/2_puzzles/assignment_19/.classpath create mode 100644 Ahmad/2_puzzles/assignment_19/.gitignore create mode 100644 Ahmad/2_puzzles/assignment_19/.project create mode 100644 Ahmad/2_puzzles/assignment_19/.settings/org.eclipse.core.resources.prefs create mode 100644 Ahmad/2_puzzles/assignment_19/.settings/org.eclipse.jdt.core.prefs create mode 100644 Ahmad/2_puzzles/assignment_19/src/assignment_19/App.java create mode 100644 Ahmad/2_puzzles/assignment_19/src/ignore/TestingUtils.java create mode 100644 Ahmad/2_puzzles/assignment_n/.classpath create mode 100644 Ahmad/2_puzzles/assignment_n/.gitignore create mode 100644 Ahmad/2_puzzles/assignment_n/.project create mode 100644 Ahmad/2_puzzles/assignment_n/.settings/org.eclipse.core.resources.prefs create mode 100644 Ahmad/2_puzzles/assignment_n/.settings/org.eclipse.jdt.core.prefs create mode 100644 Ahmad/2_puzzles/assignment_n/src/assignment_n/App.java create mode 100644 Ahmad/2_puzzles/assignment_n/src/ignore/TestingUtils.java create mode 100644 Ahmad/2_puzzles/assignment_n/src/module-info.java 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/2_puzzles/assignment_n/.project b/Ahmad/2_puzzles/assignment_n/.project new file mode 100644 index 0000000..f4c113f --- /dev/null +++ b/Ahmad/2_puzzles/assignment_n/.project @@ -0,0 +1,17 @@ + + + assignment_n + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + 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