From b643a4c488a249f5da91b7765195f404c78c6f28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CA1-4U2T1NN=E2=80=9D?= <“a1.austinn19@gmail.com”> Date: Wed, 16 Oct 2024 15:19:05 +0000 Subject: [PATCH 1/6] feat: created chigazograham.json file --- .../main/resources/data/chigazograham.json | 92 +++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 lesson_09/types/types_app/src/main/resources/data/chigazograham.json diff --git a/lesson_09/types/types_app/src/main/resources/data/chigazograham.json b/lesson_09/types/types_app/src/main/resources/data/chigazograham.json new file mode 100644 index 000000000..292620c54 --- /dev/null +++ b/lesson_09/types/types_app/src/main/resources/data/chigazograham.json @@ -0,0 +1,92 @@ +[ + { + "column1": "ms1wuglcnp", + "column2": "true", + "column3": "6463003749233522688", + "column4": "2.7921879E38", + "column5": "8.442422875678673E307", + "column6": "4743", + "column7": "1270272283" + }, + { + "column1": "7awo0gh", + "column2": "false", + "column3": "7752118028902647808", + "column4": "2.6698281E38", + "column5": "5.605056226818231E307", + "column6": "23516", + "column7": "1704066280" + }, + { + "column1": "cserf78x02", + "column2": "false", + "column3": "2540472457630355968", + "column4": "1.5396288E38", + "column5": "1.50417665803363E308", + "column6": "14580", + "column7": "2114160244" + }, + { + "column1": "zgqnjh5", + "column2": "false", + "column3": "953741867660372224", + "column4": "2.2381432E38", + "column5": "2.493477176095576E307", + "column6": "26539", + "column7": "996751379" + }, + { + "column1": "s5iqo80h3c", + "column2": "false", + "column3": "5714943984670955520", + "column4": "1.932927E38", + "column5": "1.705202914715676E308", + "column6": "7442", + "column7": "1112427416" + }, + { + "column1": "wcuo0zxejh", + "column2": "false", + "column3": "2704740152448495104", + "column4": "1.0179288E38", + "column5": "1.393686380125556E308", + "column6": "32762", + "column7": "1881329776" + }, + { + "column1": "cnq9kjd6hiu", + "column2": "true", + "column3": "6206221245541992448", + "column4": "1.3631897E38", + "column5": "1.2956738103127734E308", + "column6": "30578", + "column7": "1147532001" + }, + { + "column1": "8z0bnd", + "column2": "false", + "column3": "4562348053081931776", + "column4": "1.4620677E38", + "column5": "2.044622864892074E307", + "column6": "17197", + "column7": "1094615070" + }, + { + "column1": "0vl9htqrw", + "column2": "false", + "column3": "6077936030977995776", + "column4": "1.7550462E38", + "column5": "4.752956293100593E307", + "column6": "12867", + "column7": "724629435" + }, + { + "column1": "6ur49", + "column2": "true", + "column3": "1339556241029906688", + "column4": "1.944709E38", + "column5": "9.16514287771922E307", + "column6": "20363", + "column7": "562533284" + } +] \ No newline at end of file From 68ccb5fae54e5e7c969f4a4ace4c2947e82813e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CA1-4U2T1NN=E2=80=9D?= <“a1.austinn19@gmail.com”> Date: Wed, 16 Oct 2024 19:01:53 +0000 Subject: [PATCH 2/6] fix: deleted lesson_09 content from main; --- .../main/resources/data/chigazograham.json | 92 ------------------- 1 file changed, 92 deletions(-) delete mode 100644 lesson_09/types/types_app/src/main/resources/data/chigazograham.json diff --git a/lesson_09/types/types_app/src/main/resources/data/chigazograham.json b/lesson_09/types/types_app/src/main/resources/data/chigazograham.json deleted file mode 100644 index 292620c54..000000000 --- a/lesson_09/types/types_app/src/main/resources/data/chigazograham.json +++ /dev/null @@ -1,92 +0,0 @@ -[ - { - "column1": "ms1wuglcnp", - "column2": "true", - "column3": "6463003749233522688", - "column4": "2.7921879E38", - "column5": "8.442422875678673E307", - "column6": "4743", - "column7": "1270272283" - }, - { - "column1": "7awo0gh", - "column2": "false", - "column3": "7752118028902647808", - "column4": "2.6698281E38", - "column5": "5.605056226818231E307", - "column6": "23516", - "column7": "1704066280" - }, - { - "column1": "cserf78x02", - "column2": "false", - "column3": "2540472457630355968", - "column4": "1.5396288E38", - "column5": "1.50417665803363E308", - "column6": "14580", - "column7": "2114160244" - }, - { - "column1": "zgqnjh5", - "column2": "false", - "column3": "953741867660372224", - "column4": "2.2381432E38", - "column5": "2.493477176095576E307", - "column6": "26539", - "column7": "996751379" - }, - { - "column1": "s5iqo80h3c", - "column2": "false", - "column3": "5714943984670955520", - "column4": "1.932927E38", - "column5": "1.705202914715676E308", - "column6": "7442", - "column7": "1112427416" - }, - { - "column1": "wcuo0zxejh", - "column2": "false", - "column3": "2704740152448495104", - "column4": "1.0179288E38", - "column5": "1.393686380125556E308", - "column6": "32762", - "column7": "1881329776" - }, - { - "column1": "cnq9kjd6hiu", - "column2": "true", - "column3": "6206221245541992448", - "column4": "1.3631897E38", - "column5": "1.2956738103127734E308", - "column6": "30578", - "column7": "1147532001" - }, - { - "column1": "8z0bnd", - "column2": "false", - "column3": "4562348053081931776", - "column4": "1.4620677E38", - "column5": "2.044622864892074E307", - "column6": "17197", - "column7": "1094615070" - }, - { - "column1": "0vl9htqrw", - "column2": "false", - "column3": "6077936030977995776", - "column4": "1.7550462E38", - "column5": "4.752956293100593E307", - "column6": "12867", - "column7": "724629435" - }, - { - "column1": "6ur49", - "column2": "true", - "column3": "1339556241029906688", - "column4": "1.944709E38", - "column5": "9.16514287771922E307", - "column6": "20363", - "column7": "562533284" - } -] \ No newline at end of file From aab1baa521d8d2aaffb720092448f8ab8aa3558f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CA1-4U2T1NN=E2=80=9D?= <“a1.austinn19@gmail.com”> Date: Wed, 23 Oct 2024 14:45:56 +0000 Subject: [PATCH 3/6] feat: reconstructed lesson 12 assignment --- .../codedifferently/lesson12/Lesson12.java | 40 ++++++++++++++++--- 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/lesson_12/structs_java/structs_app/src/main/java/com/codedifferently/lesson12/Lesson12.java b/lesson_12/structs_java/structs_app/src/main/java/com/codedifferently/lesson12/Lesson12.java index af7663e90..49b15cde0 100644 --- a/lesson_12/structs_java/structs_app/src/main/java/com/codedifferently/lesson12/Lesson12.java +++ b/lesson_12/structs_java/structs_app/src/main/java/com/codedifferently/lesson12/Lesson12.java @@ -1,12 +1,40 @@ package com.codedifferently.lesson12; + public class Lesson12 { - /** - * Provide the solution to LeetCode 3062 here: - * https://github.com/yang-su2000/Leetcode-algorithm-practice/tree/master/3062-winner-of-the-linked-list-game - */ - public String gameResult(ListNode head) { - return null; + + /** + * Provide the solution to LeetCode 3062 here: + * https://github.com/yang-su2000/Leetcode-algorithm-practice/tree/master/3062-winner-of-the-linked-list-game + */ + public String gameResult(ListNode head) { + int evenCounter = 0; //Keeps track of even score + int oddCounter = 0; //Keeps track of odd score + + + int evenValue = head.val; //Makes the first even value to compare equal to the first number of the list + int oddValue = head.next.val; //Makes the first odd value to compare equal to the second number of the list + + + if ( evenValue > oddValue ) { + evenCounter = evenCounter + 1; + //Compares the even and odd value, adds 1 to even score if even is greater + } else { + oddCounter = ++oddCounter + 1; + } //Compares the even and odd value, adds 1 to odd score if odd is greater + + + if (evenCounter > oddCounter) { + return "Even"; + //Compares the even and odd score, prints 'Even' if Evens score is greater + } if (evenCounter < oddCounter) { + return "Odd"; + //Compares the even and odd score, prints 'Odd' if odds score is greater + } else { + return "Tie"; + } //Compares the even and odd score, prints 'Tie' if the two scores are equal + } + } From 0362fcb24800372af7aef35c1039c4e9405996e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CA1-4U2T1NN=E2=80=9D?= <“a1.austinn19@gmail.com”> Date: Wed, 23 Oct 2024 16:08:40 +0000 Subject: [PATCH 4/6] feat: added stack code while trying to fix a testing error; --- .../codedifferently/lesson12/Lesson12.java | 29 ++++++++++--------- .../com/codedifferently/lesson12/Stack.java | 20 ++++++++++--- 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/lesson_12/structs_java/structs_app/src/main/java/com/codedifferently/lesson12/Lesson12.java b/lesson_12/structs_java/structs_app/src/main/java/com/codedifferently/lesson12/Lesson12.java index 49b15cde0..37d13a43b 100644 --- a/lesson_12/structs_java/structs_app/src/main/java/com/codedifferently/lesson12/Lesson12.java +++ b/lesson_12/structs_java/structs_app/src/main/java/com/codedifferently/lesson12/Lesson12.java @@ -1,6 +1,5 @@ package com.codedifferently.lesson12; - public class Lesson12 { @@ -9,21 +8,23 @@ public class Lesson12 { * https://github.com/yang-su2000/Leetcode-algorithm-practice/tree/master/3062-winner-of-the-linked-list-game */ public String gameResult(ListNode head) { - int evenCounter = 0; //Keeps track of even score - int oddCounter = 0; //Keeps track of odd score - + int evenCounter = 0; //Keeps track of even score + int oddCounter = 0; //Keeps track of odd score - int evenValue = head.val; //Makes the first even value to compare equal to the first number of the list - int oddValue = head.next.val; //Makes the first odd value to compare equal to the second number of the list + while(head != null && head.next != null) { //Goes through the Linked List until theres no more pairs + int evenValue = head.val; //Makes the first even value to compare equal to the first number of the list + int oddValue = head.next.val; //Makes the first odd value to compare equal to the second number of the list - if ( evenValue > oddValue ) { - evenCounter = evenCounter + 1; - //Compares the even and odd value, adds 1 to even score if even is greater - } else { - oddCounter = ++oddCounter + 1; - } //Compares the even and odd value, adds 1 to odd score if odd is greater - + if ( evenValue > oddValue ) { + evenCounter = evenCounter + 1; + //Compares the even and odd value, adds 1 to even score if even is greater + } else { + oddCounter = oddCounter + 1; + } //Compares the even and odd value, adds 1 to odd score if odd is greater + // head.val = head.next.val; //Brings out the next pair befor restarting the loop + head = head.next; //Brings out the next pair befor restarting the loop + } if (evenCounter > oddCounter) { return "Even"; @@ -34,7 +35,7 @@ public String gameResult(ListNode head) { } else { return "Tie"; } //Compares the even and odd score, prints 'Tie' if the two scores are equal - + } } diff --git a/lesson_12/structs_java/structs_app/src/main/java/com/codedifferently/lesson12/Stack.java b/lesson_12/structs_java/structs_app/src/main/java/com/codedifferently/lesson12/Stack.java index 8444fceca..93469733a 100644 --- a/lesson_12/structs_java/structs_app/src/main/java/com/codedifferently/lesson12/Stack.java +++ b/lesson_12/structs_java/structs_app/src/main/java/com/codedifferently/lesson12/Stack.java @@ -9,18 +9,30 @@ public Stack() { } public void push(int value) { - // Your code here + var newTop = new ListNode(value); + newTop.next = top; + top = newTop; } public int pop() { - return 0; + int newTop = 0; + if(isEmpty()){ + throw new IllegalStateException("Stack is empty"); + }else{ + newTop = top.val; + top = top.next; + return newTop; + } } public int peek() { - return 0; + if(isEmpty()){ + throw new IllegalStateException("Stack is empty"); + } + return top.val; } public boolean isEmpty() { - return true; + return top == null; } } From a0d650e018ba2fd67168fb3ae7cb18584f63e4ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CA1-4U2T1NN=E2=80=9D?= <“a1.austinn19@gmail.com”> Date: Wed, 23 Oct 2024 17:06:45 +0000 Subject: [PATCH 5/6] chore: simplified counter incraments; fix: changed head.next to head.next.next; --- .../java/com/codedifferently/lesson12/Lesson12.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lesson_12/structs_java/structs_app/src/main/java/com/codedifferently/lesson12/Lesson12.java b/lesson_12/structs_java/structs_app/src/main/java/com/codedifferently/lesson12/Lesson12.java index 37d13a43b..317ed14e5 100644 --- a/lesson_12/structs_java/structs_app/src/main/java/com/codedifferently/lesson12/Lesson12.java +++ b/lesson_12/structs_java/structs_app/src/main/java/com/codedifferently/lesson12/Lesson12.java @@ -16,14 +16,13 @@ public String gameResult(ListNode head) { int oddValue = head.next.val; //Makes the first odd value to compare equal to the second number of the list - if ( evenValue > oddValue ) { - evenCounter = evenCounter + 1; + if (evenValue > oddValue) { + evenCounter++; //Compares the even and odd value, adds 1 to even score if even is greater - } else { - oddCounter = oddCounter + 1; + } else if (evenValue < oddValue) { + oddCounter++; } //Compares the even and odd value, adds 1 to odd score if odd is greater - // head.val = head.next.val; //Brings out the next pair befor restarting the loop - head = head.next; //Brings out the next pair befor restarting the loop + head = head.next.next; //Brings out the next pair befor restarting the loop } if (evenCounter > oddCounter) { From 6b95e3bdf4c7c9cd99e5124b1fed862beb545236 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CA1-4U2T1NN=E2=80=9D?= <“a1.austinn19@gmail.com”> Date: Wed, 23 Oct 2024 20:13:58 +0000 Subject: [PATCH 6/6] fix: corrected formating in lesson 12 assignments; --- .../codedifferently/lesson12/Lesson12.java | 55 ++++++++++--------- .../com/codedifferently/lesson12/Stack.java | 6 +- 2 files changed, 31 insertions(+), 30 deletions(-) diff --git a/lesson_12/structs_java/structs_app/src/main/java/com/codedifferently/lesson12/Lesson12.java b/lesson_12/structs_java/structs_app/src/main/java/com/codedifferently/lesson12/Lesson12.java index 317ed14e5..0bb2e826f 100644 --- a/lesson_12/structs_java/structs_app/src/main/java/com/codedifferently/lesson12/Lesson12.java +++ b/lesson_12/structs_java/structs_app/src/main/java/com/codedifferently/lesson12/Lesson12.java @@ -2,39 +2,40 @@ public class Lesson12 { - - /** - * Provide the solution to LeetCode 3062 here: - * https://github.com/yang-su2000/Leetcode-algorithm-practice/tree/master/3062-winner-of-the-linked-list-game - */ - public String gameResult(ListNode head) { - int evenCounter = 0; //Keeps track of even score - int oddCounter = 0; //Keeps track of odd score - - while(head != null && head.next != null) { //Goes through the Linked List until theres no more pairs - int evenValue = head.val; //Makes the first even value to compare equal to the first number of the list - int oddValue = head.next.val; //Makes the first odd value to compare equal to the second number of the list - + /** + * Provide the solution to LeetCode 3062 here: + * https://github.com/yang-su2000/Leetcode-algorithm-practice/tree/master/3062-winner-of-the-linked-list-game + */ + public String gameResult(ListNode head) { + int evenCounter = 0; // Keeps track of even score + int oddCounter = 0; // Keeps track of odd score + + while (head != null + && head.next != null) { // Goes through the Linked List until theres no more pairs + int evenValue = + head.val; // Makes the first even value to compare equal to the first number of the list + int oddValue = + head.next + .val; // Makes the first odd value to compare equal to the second number of the list if (evenValue > oddValue) { evenCounter++; - //Compares the even and odd value, adds 1 to even score if even is greater + // Compares the even and odd value, adds 1 to even score if even is greater } else if (evenValue < oddValue) { oddCounter++; - } //Compares the even and odd value, adds 1 to odd score if odd is greater - head = head.next.next; //Brings out the next pair befor restarting the loop + } // Compares the even and odd value, adds 1 to odd score if odd is greater + head = head.next.next; // Brings out the next pair befor restarting the loop } - if (evenCounter > oddCounter) { - return "Even"; - //Compares the even and odd score, prints 'Even' if Evens score is greater - } if (evenCounter < oddCounter) { - return "Odd"; - //Compares the even and odd score, prints 'Odd' if odds score is greater - } else { - return "Tie"; - } //Compares the even and odd score, prints 'Tie' if the two scores are equal - + if (evenCounter > oddCounter) { + return "Even"; + // Compares the even and odd score, prints 'Even' if Evens score is greater + } + if (evenCounter < oddCounter) { + return "Odd"; + // Compares the even and odd score, prints 'Odd' if odds score is greater + } else { + return "Tie"; + } // Compares the even and odd score, prints 'Tie' if the two scores are equal } - } diff --git a/lesson_12/structs_java/structs_app/src/main/java/com/codedifferently/lesson12/Stack.java b/lesson_12/structs_java/structs_app/src/main/java/com/codedifferently/lesson12/Stack.java index 93469733a..1e3c614c5 100644 --- a/lesson_12/structs_java/structs_app/src/main/java/com/codedifferently/lesson12/Stack.java +++ b/lesson_12/structs_java/structs_app/src/main/java/com/codedifferently/lesson12/Stack.java @@ -16,9 +16,9 @@ public void push(int value) { public int pop() { int newTop = 0; - if(isEmpty()){ + if (isEmpty()) { throw new IllegalStateException("Stack is empty"); - }else{ + } else { newTop = top.val; top = top.next; return newTop; @@ -26,7 +26,7 @@ public int pop() { } public int peek() { - if(isEmpty()){ + if (isEmpty()) { throw new IllegalStateException("Stack is empty"); } return top.val;