File tree Expand file tree Collapse file tree 4 files changed +15
-4
lines changed
main/java/de/havox_design/aoc2015/day04
test/java/de/havox_design/aoc2015/day04 Expand file tree Collapse file tree 4 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ plugins {
44
55// project meta data
66group ' de.havox_design.aoc2015'
7- version ' 0.3.2 '
7+ version ' 0.3.3 '
88
99// Switch to gradle "all" distribution.
1010wrapper {
Original file line number Diff line number Diff line change 11dependencies {
2+ implementation ' commons-codec:commons-codec:1.16.0'
23}
Original file line number Diff line number Diff line change 11package de .havox_design .aoc2015 .day04 ;
22
33import de .havox_design .aoc2015 .utils .DataReader ;
4+ import org .apache .commons .codec .digest .DigestUtils ;
45
56import java .util .List ;
67
@@ -22,7 +23,16 @@ public static int solvePart2(String fileName) {
2223 }
2324
2425 public int solvePart1 () {
25- return 0 ;
26+ for (int i = 0 ; i < Integer .MAX_VALUE ; i ++) {
27+ String combinedKey = input + i ;
28+ String md5Hash = DigestUtils .md5Hex (combinedKey );
29+
30+ if (md5Hash .startsWith ("00000" )) {
31+ return i ;
32+ }
33+ }
34+
35+ throw new IllegalStateException ("An valid hash should be able to be found." );
2636 }
2737
2838 public int solvePart2 () {
Original file line number Diff line number Diff line change @@ -18,8 +18,8 @@ void testMainClass() {
1818
1919 @ ParameterizedTest
2020 @ MethodSource ("getDataForPart1" )
21- void testPart1 (String fileName , int expectedHousesVisited ) {
22- Assertions .assertEquals (expectedHousesVisited , AdventCoins .solvePart1 (fileName ));
21+ void testPart1 (String fileName , int expectedSecretNumber ) {
22+ Assertions .assertEquals (expectedSecretNumber , AdventCoins .solvePart1 (fileName ));
2323 }
2424
2525 private static Stream <Arguments > getDataForPart1 () {
You can’t perform that action at this time.
0 commit comments