From fe6f19ef52b07684c256398feb5c81b6b76ac6ea Mon Sep 17 00:00:00 2001 From: Eoghan Conlon Date: Mon, 9 Dec 2024 11:59:50 +0000 Subject: [PATCH 1/8] Day03 initial commit Signed-off-by: Eoghan Conlon --- src/Day03.java | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/Main.java | 13 ++++++++++++- 2 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 src/Day03.java diff --git a/src/Day03.java b/src/Day03.java new file mode 100644 index 0000000..cc55cdd --- /dev/null +++ b/src/Day03.java @@ -0,0 +1,51 @@ +import java.io.IOException; + +public class Day03 extends Input { + private Input input; + + public Day03() throws IOException { + input = new Input(); + input.init("in/Day03"); + } + + public int part1_sample(){ + int rValue = 0; + + String input = this.input.getSample_input().getFirst(); + String pattern = "mul("; + String num1_s = ""; + String num2_s = ""; + String nums = "0123456789"; + int num = 1; + int pattern_cnt = 0; + for(int i = 0; i < input.length(); i += 1){ + if(pattern_cnt != pattern.length()) { + if (input.charAt(i) == pattern.charAt(pattern_cnt)) { + pattern_cnt += 1; + } else { + pattern_cnt = 0; + } + } else { + if(nums.contains(Character.toString(input.charAt(i)))){ + if(num == 1){ + num1_s += input.charAt(i); + } else if (num == 2) { + num2_s += input.charAt(i); + } else { + System.err.println("Something went wrong"); + } + } else if (input.charAt(i) == ',' && num == 1){ + num += 1; + } else if (input.charAt(i) == ')' && num == 2){ + int num1 = Integer.parseInt(num1_s); + int num2 = Integer.parseInt(num2_s); + rValue += (num1 * num2); + num = 1; + pattern_cnt = 0; + } + } + } + + return rValue; + } +} diff --git a/src/Main.java b/src/Main.java index 7066f74..be8e5d9 100644 --- a/src/Main.java +++ b/src/Main.java @@ -24,10 +24,21 @@ public class Main { int d1_p2_answer = day01.Part2(); long day01_p2 = System.currentTimeMillis() - start; + start = System.currentTimeMillis(); + Day03 day03 = new Day03(); + long day03_init = System.currentTimeMillis() - start; + + start = System.currentTimeMillis(); + int day03_p1_sample = day03.part1_sample(); + long day03_p1_sample_t = System.currentTimeMillis() - start; + System.out.printf("Day 1 init took %dms", day01_init); System.out.printf("Part 1 sample is: %d (%dms)\n", sample_d1_p1_answer, day01_p1_sample); System.out.printf("Part 1 answer is: %d (%dms)\n", d1_p1_answer, day01_p1); System.out.printf("Part 2 sample answer is: %d (%dms)\n", sample_d1_p2_answer, day01_p2_sample); - System.out.printf("Part 2 answer is: %d (%dms)", d1_p2_answer, day01_p2); + System.out.printf("Part 2 answer is: %d (%dms)\n", d1_p2_answer, day01_p2); + + System.out.printf("Day 3 init took %dms\n", day03_init); + System.out.printf("Day 3 part 1 (sample): %d (%dms)\n", day03_p1_sample, day03_p1_sample_t); } } From bb85b88e352e76c75e7ed1fe2665c24057f812ea Mon Sep 17 00:00:00 2001 From: Eoghan Conlon Date: Mon, 9 Dec 2024 12:01:28 +0000 Subject: [PATCH 2/8] Day03 p1 Fix. Resetting the number strings Signed-off-by: Eoghan Conlon --- src/Day03.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Day03.java b/src/Day03.java index cc55cdd..89db8e9 100644 --- a/src/Day03.java +++ b/src/Day03.java @@ -42,6 +42,13 @@ public class Day03 extends Input { rValue += (num1 * num2); num = 1; pattern_cnt = 0; + num1_s = ""; + num2_s = ""; + } else { + num = 1; + pattern_cnt = 0; + num1_s = ""; + num2_s = ""; } } } From 922c9913858ac4489eaa95e24fe27d95990958d5 Mon Sep 17 00:00:00 2001 From: Eoghan Conlon Date: Mon, 9 Dec 2024 12:03:42 +0000 Subject: [PATCH 3/8] Day03 p1 Fix. Changing sample function to match what the input function uses Signed-off-by: Eoghan Conlon --- src/Day03.java | 71 +++++++++++++++++++++++++------------------------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/src/Day03.java b/src/Day03.java index 89db8e9..b20a2e4 100644 --- a/src/Day03.java +++ b/src/Day03.java @@ -11,44 +11,45 @@ public class Day03 extends Input { public int part1_sample(){ int rValue = 0; - String input = this.input.getSample_input().getFirst(); - String pattern = "mul("; - String num1_s = ""; - String num2_s = ""; - String nums = "0123456789"; - int num = 1; - int pattern_cnt = 0; - for(int i = 0; i < input.length(); i += 1){ - if(pattern_cnt != pattern.length()) { - if (input.charAt(i) == pattern.charAt(pattern_cnt)) { - pattern_cnt += 1; - } else { - pattern_cnt = 0; - } - } else { - if(nums.contains(Character.toString(input.charAt(i)))){ - if(num == 1){ - num1_s += input.charAt(i); - } else if (num == 2) { - num2_s += input.charAt(i); + for(String input : this.input.getSample_input()) { + String pattern = "mul("; + String num1_s = ""; + String num2_s = ""; + String nums = "0123456789"; + int num = 1; + int pattern_cnt = 0; + for (int i = 0; i < input.length(); i += 1) { + if (pattern_cnt != pattern.length()) { + if (input.charAt(i) == pattern.charAt(pattern_cnt)) { + pattern_cnt += 1; } else { - System.err.println("Something went wrong"); + pattern_cnt = 0; } - } else if (input.charAt(i) == ',' && num == 1){ - num += 1; - } else if (input.charAt(i) == ')' && num == 2){ - int num1 = Integer.parseInt(num1_s); - int num2 = Integer.parseInt(num2_s); - rValue += (num1 * num2); - num = 1; - pattern_cnt = 0; - num1_s = ""; - num2_s = ""; } else { - num = 1; - pattern_cnt = 0; - num1_s = ""; - num2_s = ""; + if (nums.contains(Character.toString(input.charAt(i)))) { + if (num == 1) { + num1_s += input.charAt(i); + } else if (num == 2) { + num2_s += input.charAt(i); + } else { + System.err.println("Something went wrong"); + } + } else if (input.charAt(i) == ',' && num == 1) { + num += 1; + } else if (input.charAt(i) == ')' && num == 2) { + int num1 = Integer.parseInt(num1_s); + int num2 = Integer.parseInt(num2_s); + rValue += (num1 * num2); + num = 1; + pattern_cnt = 0; + num1_s = ""; + num2_s = ""; + } else { + num = 1; + pattern_cnt = 0; + num1_s = ""; + num2_s = ""; + } } } } From c5d08570e8b51059edb967467aea13e514142ff4 Mon Sep 17 00:00:00 2001 From: Eoghan Conlon Date: Mon, 9 Dec 2024 12:07:00 +0000 Subject: [PATCH 4/8] Day03 p1 Feat. Part 1 solution complete Signed-off-by: Eoghan Conlon --- src/Day03.java | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ src/Main.java | 5 +++++ 2 files changed, 54 insertions(+) diff --git a/src/Day03.java b/src/Day03.java index b20a2e4..43cfbfc 100644 --- a/src/Day03.java +++ b/src/Day03.java @@ -56,4 +56,53 @@ public class Day03 extends Input { return rValue; } + + public int part1(){ + int rValue = 0; + + for(String input : this.input.getInput()) { + String pattern = "mul("; + String num1_s = ""; + String num2_s = ""; + String nums = "0123456789"; + int num = 1; + int pattern_cnt = 0; + for (int i = 0; i < input.length(); i += 1) { + if (pattern_cnt != pattern.length()) { + if (input.charAt(i) == pattern.charAt(pattern_cnt)) { + pattern_cnt += 1; + } else { + pattern_cnt = 0; + } + } else { + if (nums.contains(Character.toString(input.charAt(i)))) { + if (num == 1) { + num1_s += input.charAt(i); + } else if (num == 2) { + num2_s += input.charAt(i); + } else { + System.err.println("Something went wrong"); + } + } else if (input.charAt(i) == ',' && num == 1) { + num += 1; + } else if (input.charAt(i) == ')' && num == 2) { + int num1 = Integer.parseInt(num1_s); + int num2 = Integer.parseInt(num2_s); + rValue += (num1 * num2); + num = 1; + pattern_cnt = 0; + num1_s = ""; + num2_s = ""; + } else { + num = 1; + pattern_cnt = 0; + num1_s = ""; + num2_s = ""; + } + } + } + } + + return rValue; + } } diff --git a/src/Main.java b/src/Main.java index be8e5d9..c3df515 100644 --- a/src/Main.java +++ b/src/Main.java @@ -32,6 +32,10 @@ public class Main { int day03_p1_sample = day03.part1_sample(); long day03_p1_sample_t = System.currentTimeMillis() - start; + start = System.currentTimeMillis(); + int day03_p1 = day03.part1(); + long day03_p1_t = System.currentTimeMillis() - start; + System.out.printf("Day 1 init took %dms", day01_init); System.out.printf("Part 1 sample is: %d (%dms)\n", sample_d1_p1_answer, day01_p1_sample); System.out.printf("Part 1 answer is: %d (%dms)\n", d1_p1_answer, day01_p1); @@ -40,5 +44,6 @@ public class Main { System.out.printf("Day 3 init took %dms\n", day03_init); System.out.printf("Day 3 part 1 (sample): %d (%dms)\n", day03_p1_sample, day03_p1_sample_t); + System.out.printf("Day 3 part 2 : %d (%dms)", day03_p1, day03_p1_t); } } From c653c05a0651465713bf6440677bef0a72286fb3 Mon Sep 17 00:00:00 2001 From: Eoghan Conlon Date: Mon, 9 Dec 2024 13:03:33 +0000 Subject: [PATCH 5/8] Refactor main to match format used Signed-off-by: Eoghan Conlon --- src/Main.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Main.java b/src/Main.java index c3df515..0167df9 100644 --- a/src/Main.java +++ b/src/Main.java @@ -24,6 +24,13 @@ public class Main { int d1_p2_answer = day01.Part2(); long day01_p2 = System.currentTimeMillis() - start; + System.out.printf("Day 1 init took %dms", day01_init); + System.out.printf("Part 1 sample is: %d (%dms)\n", sample_d1_p1_answer, day01_p1_sample); + System.out.printf("Part 1 answer is: %d (%dms)\n", d1_p1_answer, day01_p1); + System.out.printf("Part 2 sample answer is: %d (%dms)\n", sample_d1_p2_answer, day01_p2_sample); + System.out.printf("Part 2 answer is: %d (%dms)\n", d1_p2_answer, day01_p2); + + System.out.println("\nDay 3:"); start = System.currentTimeMillis(); Day03 day03 = new Day03(); long day03_init = System.currentTimeMillis() - start; @@ -36,12 +43,6 @@ public class Main { int day03_p1 = day03.part1(); long day03_p1_t = System.currentTimeMillis() - start; - System.out.printf("Day 1 init took %dms", day01_init); - System.out.printf("Part 1 sample is: %d (%dms)\n", sample_d1_p1_answer, day01_p1_sample); - System.out.printf("Part 1 answer is: %d (%dms)\n", d1_p1_answer, day01_p1); - System.out.printf("Part 2 sample answer is: %d (%dms)\n", sample_d1_p2_answer, day01_p2_sample); - System.out.printf("Part 2 answer is: %d (%dms)\n", d1_p2_answer, day01_p2); - System.out.printf("Day 3 init took %dms\n", day03_init); System.out.printf("Day 3 part 1 (sample): %d (%dms)\n", day03_p1_sample, day03_p1_sample_t); System.out.printf("Day 3 part 2 : %d (%dms)", day03_p1, day03_p1_t); From 67dd1ee1e5dc6f970a73f054d6ba1bff225f8e1a Mon Sep 17 00:00:00 2001 From: Eoghan Conlon Date: Mon, 9 Dec 2024 13:27:31 +0000 Subject: [PATCH 6/8] Day 03 p1 Reafctored code to split logic into function to reuse for p2 Signed-off-by: Eoghan Conlon --- src/Day03.java | 127 ++++++++++++++++++------------------------------- 1 file changed, 47 insertions(+), 80 deletions(-) diff --git a/src/Day03.java b/src/Day03.java index 43cfbfc..113dc18 100644 --- a/src/Day03.java +++ b/src/Day03.java @@ -12,46 +12,7 @@ public class Day03 extends Input { int rValue = 0; for(String input : this.input.getSample_input()) { - String pattern = "mul("; - String num1_s = ""; - String num2_s = ""; - String nums = "0123456789"; - int num = 1; - int pattern_cnt = 0; - for (int i = 0; i < input.length(); i += 1) { - if (pattern_cnt != pattern.length()) { - if (input.charAt(i) == pattern.charAt(pattern_cnt)) { - pattern_cnt += 1; - } else { - pattern_cnt = 0; - } - } else { - if (nums.contains(Character.toString(input.charAt(i)))) { - if (num == 1) { - num1_s += input.charAt(i); - } else if (num == 2) { - num2_s += input.charAt(i); - } else { - System.err.println("Something went wrong"); - } - } else if (input.charAt(i) == ',' && num == 1) { - num += 1; - } else if (input.charAt(i) == ')' && num == 2) { - int num1 = Integer.parseInt(num1_s); - int num2 = Integer.parseInt(num2_s); - rValue += (num1 * num2); - num = 1; - pattern_cnt = 0; - num1_s = ""; - num2_s = ""; - } else { - num = 1; - pattern_cnt = 0; - num1_s = ""; - num2_s = ""; - } - } - } + rValue += getMul(input); } return rValue; @@ -61,48 +22,54 @@ public class Day03 extends Input { int rValue = 0; for(String input : this.input.getInput()) { - String pattern = "mul("; - String num1_s = ""; - String num2_s = ""; - String nums = "0123456789"; - int num = 1; - int pattern_cnt = 0; - for (int i = 0; i < input.length(); i += 1) { - if (pattern_cnt != pattern.length()) { - if (input.charAt(i) == pattern.charAt(pattern_cnt)) { - pattern_cnt += 1; - } else { - pattern_cnt = 0; - } - } else { - if (nums.contains(Character.toString(input.charAt(i)))) { - if (num == 1) { - num1_s += input.charAt(i); - } else if (num == 2) { - num2_s += input.charAt(i); - } else { - System.err.println("Something went wrong"); - } - } else if (input.charAt(i) == ',' && num == 1) { - num += 1; - } else if (input.charAt(i) == ')' && num == 2) { - int num1 = Integer.parseInt(num1_s); - int num2 = Integer.parseInt(num2_s); - rValue += (num1 * num2); - num = 1; - pattern_cnt = 0; - num1_s = ""; - num2_s = ""; - } else { - num = 1; - pattern_cnt = 0; - num1_s = ""; - num2_s = ""; - } - } - } + rValue += getMul(input); } return rValue; } + + private int getMul(String input){ + int rValue = 0; + String pattern = "mul("; + String num1_s = ""; + String num2_s = ""; + String nums = "0123456789"; + int num = 1; + int pattern_cnt = 0; + for (int i = 0; i < input.length(); i += 1) { + if (pattern_cnt != pattern.length()) { + if (input.charAt(i) == pattern.charAt(pattern_cnt)) { + pattern_cnt += 1; + } else { + pattern_cnt = 0; + } + } else { + if (nums.contains(Character.toString(input.charAt(i)))) { + if (num == 1) { + num1_s += input.charAt(i); + } else if (num == 2) { + num2_s += input.charAt(i); + } else { + System.err.println("Something went wrong"); + } + } else if (input.charAt(i) == ',' && num == 1) { + num += 1; + } else if (input.charAt(i) == ')' && num == 2) { + int num1 = Integer.parseInt(num1_s); + int num2 = Integer.parseInt(num2_s); + rValue += (num1 * num2); + num = 1; + pattern_cnt = 0; + num1_s = ""; + num2_s = ""; + } else { + num = 1; + pattern_cnt = 0; + num1_s = ""; + num2_s = ""; + } + } + } + return rValue; + } } From f755002b51512587e5896af3598fcd5b09991917 Mon Sep 17 00:00:00 2001 From: Eoghan Conlon Date: Mon, 9 Dec 2024 14:58:50 +0000 Subject: [PATCH 7/8] Day 03 p2 complete Signed-off-by: Eoghan Conlon --- src/Day03.java | 174 +++++++++++++++++++++++++++++++++++++++++++++++-- src/Main.java | 12 +++- 2 files changed, 180 insertions(+), 6 deletions(-) diff --git a/src/Day03.java b/src/Day03.java index 113dc18..17014a3 100644 --- a/src/Day03.java +++ b/src/Day03.java @@ -8,27 +8,191 @@ public class Day03 extends Input { input.init("in/Day03"); } - public int part1_sample(){ + public int part1_sample() { int rValue = 0; - for(String input : this.input.getSample_input()) { + for (String input : this.input.getSample_input()) { rValue += getMul(input); } return rValue; } - public int part1(){ + public int part1() { int rValue = 0; - for(String input : this.input.getInput()) { + for (String input : this.input.getInput()) { rValue += getMul(input); } return rValue; } - private int getMul(String input){ + public int part2_sample() { + int rValue = 0; + boolean mul = true; + String pattern_mul = "mul("; + String pattern_do = "do()"; + String pattern_dont = "don't()"; + String nums = "0123456789"; + String num1_s = ""; + String num2_s = ""; + int num = 1; + int mul_cnt = 0; + int do_cnt = 0; + for (String input : this.input.getSample_input()) { + for (int i = 0; i < input.length(); i += 1) { + if (mul) { + if (mul_cnt != pattern_mul.length()) { + if (input.charAt(i) == pattern_mul.charAt(mul_cnt)) { + do_cnt = 0; + mul_cnt += 1; + } else if (input.charAt(i) == pattern_dont.charAt(do_cnt)) { + mul_cnt = 0; + do_cnt += 1; + if (do_cnt == pattern_dont.length()) { + mul = false; + do_cnt = 0; + } + } else { + mul_cnt = 0; + } + } else if (input.charAt(i) == pattern_dont.charAt(do_cnt)) { + mul_cnt = 0; + do_cnt += 1; + if (do_cnt == pattern_dont.length()) { + mul = false; + do_cnt = 0; + } + } else if (mul_cnt == pattern_mul.length()) { + if (nums.contains(Character.toString(input.charAt(i)))) { + if (num == 1) { + num1_s += input.charAt(i); + } else if (num == 2) { + num2_s += input.charAt(i); + } else { + System.err.println("Something went wrong"); + } + } else if (input.charAt(i) == ',' && num == 1) { + num += 1; + } else if (input.charAt(i) == ')' && num == 2) { + int num1 = Integer.parseInt(num1_s); + int num2 = Integer.parseInt(num2_s); + rValue += (num1 * num2); + num = 1; + mul_cnt = 0; + num1_s = ""; + num2_s = ""; + } else { + num = 1; + mul_cnt = 0; + num1_s = ""; + num2_s = ""; + } + } else { + mul_cnt = 0; + do_cnt = 0; + } + } else { + if (input.charAt(i) == pattern_do.charAt(do_cnt)) { + do_cnt += 1; + if (do_cnt == pattern_do.length()) { + mul = true; + do_cnt = 0; + } + } else { + do_cnt = 0; + } + } + } + } + + return rValue; + } + + public int part2() { + int rValue = 0; + boolean mul = true; + String pattern_mul = "mul("; + String pattern_do = "do()"; + String pattern_dont = "don't()"; + String nums = "0123456789"; + String num1_s = ""; + String num2_s = ""; + int num = 1; + int mul_cnt = 0; + int do_cnt = 0; + for (String input : this.input.getInput()) { + for (int i = 0; i < input.length(); i += 1) { + if (mul) { + if (mul_cnt != pattern_mul.length()) { + if (input.charAt(i) == pattern_mul.charAt(mul_cnt)) { + do_cnt = 0; + mul_cnt += 1; + } else if (input.charAt(i) == pattern_dont.charAt(do_cnt)) { + mul_cnt = 0; + do_cnt += 1; + if (do_cnt == pattern_dont.length()) { + mul = false; + do_cnt = 0; + } + } else { + mul_cnt = 0; + } + } else if (input.charAt(i) == pattern_dont.charAt(do_cnt)) { + mul_cnt = 0; + do_cnt += 1; + if (do_cnt == pattern_dont.length()) { + mul = false; + do_cnt = 0; + } + } else if (mul_cnt == pattern_mul.length()) { + if (nums.contains(Character.toString(input.charAt(i)))) { + if (num == 1) { + num1_s += input.charAt(i); + } else if (num == 2) { + num2_s += input.charAt(i); + } else { + System.err.println("Something went wrong"); + } + } else if (input.charAt(i) == ',' && num == 1) { + num += 1; + } else if (input.charAt(i) == ')' && num == 2) { + int num1 = Integer.parseInt(num1_s); + int num2 = Integer.parseInt(num2_s); + rValue += (num1 * num2); + num = 1; + mul_cnt = 0; + num1_s = ""; + num2_s = ""; + } else { + num = 1; + mul_cnt = 0; + num1_s = ""; + num2_s = ""; + } + } else { + mul_cnt = 0; + do_cnt = 0; + } + } else { + if (input.charAt(i) == pattern_do.charAt(do_cnt)) { + do_cnt += 1; + if (do_cnt == pattern_do.length()) { + mul = true; + do_cnt = 0; + } + } else { + do_cnt = 0; + } + } + } + } + + return rValue; + } + + private int getMul(String input) { int rValue = 0; String pattern = "mul("; String num1_s = ""; diff --git a/src/Main.java b/src/Main.java index 0167df9..567b617 100644 --- a/src/Main.java +++ b/src/Main.java @@ -43,8 +43,18 @@ public class Main { int day03_p1 = day03.part1(); long day03_p1_t = System.currentTimeMillis() - start; + start = System.currentTimeMillis(); + int day03_p2_sample = day03.part2_sample(); + long day03_p2_sample_t = System.currentTimeMillis() - start; + + start = System.currentTimeMillis(); + int day03_p2 = day03.part2(); + long day03_p2_t = System.currentTimeMillis() - start; + System.out.printf("Day 3 init took %dms\n", day03_init); System.out.printf("Day 3 part 1 (sample): %d (%dms)\n", day03_p1_sample, day03_p1_sample_t); - System.out.printf("Day 3 part 2 : %d (%dms)", day03_p1, day03_p1_t); + System.out.printf("Day 3 part 1 : %d (%dms)\n", day03_p1, day03_p1_t); + System.out.printf("Day 3 part 2 (sample): %d (%dms)\n", day03_p2_sample, day03_p2_sample_t); + System.out.printf("Day 3 part 2: %d (%dms)", day03_p2, day03_p2_t); } } From dfac234f4494bb0b2c532742078b4a24cec68249 Mon Sep 17 00:00:00 2001 From: Eoghan Conlon Date: Mon, 9 Dec 2024 15:01:14 +0000 Subject: [PATCH 8/8] Fix. Adding Day02 stuff into main Signed-off-by: Eoghan Conlon --- src/Main.java | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/Main.java b/src/Main.java index 567b617..1d8c4fb 100644 --- a/src/Main.java +++ b/src/Main.java @@ -30,6 +30,33 @@ public class Main { System.out.printf("Part 2 sample answer is: %d (%dms)\n", sample_d1_p2_answer, day01_p2_sample); System.out.printf("Part 2 answer is: %d (%dms)\n", d1_p2_answer, day01_p2); + System.out.println("\nDay 2:"); + start = System.currentTimeMillis(); + Day02 day02 = new Day02(); + long day02_init = System.currentTimeMillis() - start; + + start = System.currentTimeMillis(); + int d2_p1_sample = day02.part1Sample(); + long day02_p1_sample = System.currentTimeMillis() - start; + + start = System.currentTimeMillis(); + int d2_p1 = day02.part1(); + long day02_p1 = System.currentTimeMillis() - start; + + start = System.currentTimeMillis(); + int d2_p2_sample = day02.part2Sample(); + long day02_p2_sample = System.currentTimeMillis() - start; + + start = System.currentTimeMillis(); + int d2_p2 = day02.part2(); + long day02_p2 = System.currentTimeMillis() - start; + + System.out.printf("Day 2 init took %dms\n", day02_init); + System.out.printf("Part 1 sample = %d (%dms)\n", d2_p1_sample, day02_p1_sample); + System.out.printf("Part 1 answer = %d (%dms)\n", d2_p1, day02_p1); + System.out.printf("Part 2 sample = %d (%dms)\n", d2_p2_sample, day02_p2_sample); + System.out.printf("Part 2 answer = %d (%dms)\n", d2_p2, day02_p2); + System.out.println("\nDay 3:"); start = System.currentTimeMillis(); Day03 day03 = new Day03();