File tree Expand file tree Collapse file tree 2 files changed +22
-3
lines changed
Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -220,7 +220,7 @@ Different scripts for day 25,
220220| 20 | S/H | picture matching/pattern search |
221221| 21 | M/S | analyze insets |
222222| 22 | S/S | cards array iteration |
223- | 23 | S/- | array iteration |
223+ | 23 | S/S | array iteration |
224224| 24 | S/S | hex flip/life game simulation |
225225| 25 | S/- | number iteration |
226226
Original file line number Diff line number Diff line change 1- const MAX = 9
1+ let MAX = 9
22
33module . exports = function ( part , data ) {
44 const numbers = data . split ( '' ) . map ( x => + x )
@@ -18,13 +18,32 @@ module.exports = function(part, data) {
1818 }
1919
2020 result = [ ]
21- let n = 8
21+ let n = MAX - 1
2222 while ( n -- ) {
2323 cur = cur . next
2424 result . push ( cur . v )
2525 }
2626 result = result . join ( '' )
2727 } else {
28+ const nmax = 1000000
29+ let prev = nodes [ numbers [ MAX - 1 ] ]
30+ for ( let i = MAX + 1 ; i <= nmax ; i ++ ) {
31+ prev . next = nodes [ i ] = { v : i }
32+ prev = prev . next
33+ }
34+ nodes [ nmax ] . next = nodes [ numbers [ 0 ] ]
35+ MAX = nmax
36+
37+ let moves = 10000000
38+ while ( moves -- ) {
39+ if ( ! ( moves % 10000 ) ) console . log ( moves )
40+
41+ update ( cur , nodes )
42+ cur = cur . next
43+ }
44+
45+ result = nodes [ 1 ] . next . v * nodes [ 1 ] . next . next . v
46+ console . log ( nodes [ 1 ] . next . v , nodes [ 1 ] . next . next . v )
2847 }
2948 console . log ( result )
3049}
You can’t perform that action at this time.
0 commit comments