File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -37,12 +37,15 @@ const findMinLocationFromSeeds = (seeds: number[], mapper: Array<Array<number>[]
37
37
38
38
console . log ( `Result for part 1 is : ${ findMinLocationFromSeeds ( seeds , mapper ) } ` )
39
39
40
- const seedsPart2 : number [ ] = [ ]
40
+ let minLocation = Infinity
41
41
for ( let i = 0 ; i < seeds . length / 2 ; i += 2 ) {
42
42
for ( let j = 0 ; j < seeds [ i + 1 ] ; j ++ ) {
43
- seedsPart2 . push ( seeds [ i ] + j )
43
+ const min = findMinLocationFromSeeds ( [ seeds [ i ] + j ] , mapper )
44
+ if ( min < minLocation ) {
45
+ console . log ( 'better min :' , min )
46
+ minLocation = min
47
+ }
44
48
}
45
49
}
46
- // TODO optimize...
47
- console . log ( seedsPart2 )
48
- //console.log(`Result for part 2 is : ${findMinLocationFromSeeds(seedsPart2, mapper)}`)
50
+
51
+ console . log ( `Result for part 2 is : ${ minLocation } ` )
You can’t perform that action at this time.
0 commit comments