File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change 1+ const { dynamicSort } = require ( '../day-04/helpers' )
12const { Rack } = require ( './fuel-cells' )
23const serial = 1133 // From puzzle input
34const size = [ 300 , 300 ]
@@ -6,7 +7,22 @@ const squareSize = [3, 3]
67let powerBank = new Rack ( serial , size )
78powerBank . tallySquares ( squareSize )
89const answer = powerBank . getCellsByPower ( squareSize ) [ 0 ] . coords
9- const answer2 = ''
10+
11+ const anySizeSquares = [ ]
12+ for ( let dial = 1 ; dial <= 5 ; dial ++ ) {
13+ powerBank . tallySquares ( [ dial , dial ] )
14+ let bestOfSizeX = powerBank . getCellsByPower ( squareSize ) [ 0 ]
15+ anySizeSquares . push ( {
16+ coords : bestOfSizeX . coords ,
17+ power : bestOfSizeX . squareTotal ,
18+ size : dial
19+ } )
20+ }
21+
22+ const bestOfAnySize = anySizeSquares . sort ( dynamicSort ( '-power' ) ) [ 0 ]
23+ let answer2 = bestOfAnySize . coords
24+ answer2 . push ( bestOfAnySize . size )
25+
1026console . log ( `-- Part 1 --` )
1127console . log ( `Answer: ${ answer } ` )
1228console . log ( `-- Part 2 --` )
You can’t perform that action at this time.
0 commit comments