File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -14,8 +14,8 @@ console.log(`-- Part 1 --`)
14
14
console . log ( `Answer: ${ answer } ` )
15
15
16
16
const anySizeSquares = [ ]
17
+ let negativeCounter = 0
17
18
for ( let dial = 1 ; dial <= 300 ; dial ++ ) {
18
- console . log ( `Measuring power with dial at ${ dial } ` )
19
19
// powerBank.tallySquares([dial, dial])
20
20
// let bestOfSizeX = powerBank.getCellsByPower(squareSize)[0]
21
21
// anySizeSquares.push({
@@ -24,11 +24,21 @@ for (let dial = 1; dial <= 300; dial++) {
24
24
// size: dial
25
25
// })
26
26
const max = powerBank . findMaxSquare ( [ dial , dial ] )
27
+ console . log ( `Max power whith dial at ${ dial } is ${ max . power } ` )
28
+
27
29
anySizeSquares . push ( {
28
30
coords : powerBank . cells [ max . idx ] . coords ,
29
31
power : max . power ,
30
32
size : dial
31
33
} )
34
+
35
+ // Watching the log, the power seems to go up as the grid size goes up, but reaches
36
+ // a limit at which point it drops of forever. Therefore, let's cap it when 5 sizes in
37
+ // a row have negative power outputs
38
+ if ( max . power < 0 ) { negativeCounter ++ }
39
+ if ( negativeCounter >= 5 ) {
40
+ break
41
+ }
32
42
}
33
43
34
44
const bestOfAnySize = anySizeSquares . sort ( dynamicSort ( '-power' ) ) [ 0 ]
You can’t perform that action at this time.
0 commit comments