File tree Expand file tree Collapse file tree 11 files changed +51
-15
lines changed
main/java/org/ck/adventofcode/year2025
java/org/ck/adventofcode/year2025
resources/org/ck/adventofcode/year2025/day03 Expand file tree Collapse file tree 11 files changed +51
-15
lines changed Original file line number Diff line number Diff line change 16581658[ 20242402tests ] : src/test/java/org/ck/adventofcode/year2024/Day24Test.java
16591659[ 20242501tests ] : src/test/java/org/ck/adventofcode/year2024/Day25Test.java
16601660
1661- # 2025 (4 /24)
1661+ # 2025 (6 /24)
16621662
16631663| # | Name | Solution | Test |
16641664| ---------:| ---------------------------------------------| :------------------------------------:| :---------------------------------:|
16651665| 20250101 | [ Day 1: Secret Entrance] [ 20250101 ] | ✅ ; [ 💾 ; ] [ 20250101solution ] | ✅ ; [ 💾 ; ] [ 20250101tests ] |
16661666| 20250102 | [ Day 1: Secret Entrance - Part 2] [ 20250102 ] | ✅ ; [ 💾 ; ] [ 20250102solution ] | ✅ ; [ 💾 ; ] [ 20250102tests ] |
16671667| 20250201 | [ Day 2: Gift Shop] [ 20250201 ] | ✅ ; [ 💾 ; ] [ 20250201solution ] | ✅ ; [ 💾 ; ] [ 20250201tests ] |
16681668| 20250202 | [ Day 2: Gift Shop - Part 2] [ 20250202 ] | ✅ ; [ 💾 ; ] [ 20250202solution ] | ✅ ; [ 💾 ; ] [ 20250202tests ] |
1669- | 20250301 | [ Day 3: ] [ 20250301 ] | [ 💾 ; ] [ 20250301solution ] | [ 💾 ; ] [ 20250301tests ] |
1670- | 20250302 | [ Day 3: - Part 2] [ 20250302 ] | [ 💾 ; ] [ 20250302solution ] | [ 💾 ; ] [ 20250302tests ] |
1669+ | 20250301 | [ Day 3: Lobby ] [ 20250301 ] | &# 9989 ; [ 💾 ; ] [ 20250301solution ] | &# 9989 ; [ 💾 ; ] [ 20250301tests ] |
1670+ | 20250302 | [ Day 3: Lobby - Part 2] [ 20250302 ] | &# 9989 ; [ 💾 ; ] [ 20250302solution ] | &# 9989 ; [ 💾 ; ] [ 20250302tests ] |
16711671| 20250401 | [ Day 4: ] [ 20250401 ] | [ 💾 ; ] [ 20250401solution ] | [ 💾 ; ] [ 20250401tests ] |
16721672| 20250402 | [ Day 4: - Part 2] [ 20250402 ] | [ 💾 ; ] [ 20250402solution ] | [ 💾 ; ] [ 20250402tests ] |
16731673| 20250501 | [ Day 5: ] [ 20250501 ] | [ 💾 ; ] [ 20250501solution ] | [ 💾 ; ] [ 20250501tests ] |
Original file line number Diff line number Diff line change 66
77@ Solution (
88 id = 20250301 ,
9- name = "Day 3: " ,
9+ name = "Day 3: Lobby " ,
1010 url = "https://adventofcode.com/2025/day/3" ,
11- category = "2025" ,
12- solved = false )
11+ category = "2025" )
1312@ Solution (
1413 id = 20250302 ,
15- name = "Day 3: - Part 2" ,
14+ name = "Day 3: Lobby - Part 2" ,
1615 url = "https://adventofcode.com/2025/day/3#part2" ,
17- category = "2025" ,
18- solved = false )
16+ category = "2025" )
1917public class Day03 extends AOCSolution {
2018
2119 @ Override
2220 protected void runPartOne (final Scanner in ) {
23- run (in );
21+ run (in , 2 );
2422 }
2523
2624 @ Override
2725 protected void runPartTwo (final Scanner in ) {
28- run (in );
26+ run (in , 12 );
2927 }
3028
31- private void run (final Scanner in ) {
32- // not yet implemented
29+ private void run (final Scanner in , final int numberOfBatteries ) {
30+ long jolts = 0 ;
31+
32+ while (in .hasNextLine ()) {
33+ final String line = in .nextLine ();
34+
35+ long currentJolts = 0 ;
36+ int startIndex = 0 ;
37+ for (int battery = numberOfBatteries - 1 ; battery >= 0 ; --battery ) {
38+ int maxValue = 0 ;
39+ int maxIndex = startIndex ;
40+ for (int i = startIndex ; i < line .length () - battery ; ++i ) {
41+ final int value = line .charAt (i ) - '0' ;
42+
43+ if (value > maxValue ) {
44+ maxValue = value ;
45+ maxIndex = i ;
46+ }
47+ }
48+
49+ startIndex = maxIndex + 1 ;
50+ currentJolts += maxValue * (long ) Math .pow (10 , battery );
51+ }
52+
53+ jolts += currentJolts ;
54+ }
55+
56+ print (jolts );
3357 }
3458}
Original file line number Diff line number Diff line change 11package org .ck .adventofcode .year2025 ;
22
33import org .ck .adventofcode .util .BaseAOCTest ;
4- import org .junit .jupiter .api .Disabled ;
54import org .junit .jupiter .params .ParameterizedTest ;
65import org .junit .jupiter .params .provider .ValueSource ;
76
8- @ Disabled
97class Day03Test extends BaseAOCTest {
108 @ ParameterizedTest
119 @ ValueSource (strings = {"01a" })
Original file line number Diff line number Diff line change 1+ 17435
Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change 1+ 357
Original file line number Diff line number Diff line change 1+ 987654321111111
2+ 811111111111119
3+ 234234234234278
4+ 818181911112111
Original file line number Diff line number Diff line change 1+ 172886048065379
Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change 1+ 3121910778619
You can’t perform that action at this time.
0 commit comments