File tree Expand file tree Collapse file tree 1 file changed +5
-8
lines changed
Expand file tree Collapse file tree 1 file changed +5
-8
lines changed Original file line number Diff line number Diff line change @@ -9,8 +9,8 @@ export function part1(input) {
99 if ( map [ curr ] [ x ] === "." ) {
1010 next . add ( x ) ;
1111 } else {
12- if ( map [ curr ] [ x - 1 ] ) next . add ( x - 1 ) ;
13- if ( map [ curr ] [ x + 1 ] ) next . add ( x + 1 ) ;
12+ next . add ( x - 1 ) ;
13+ next . add ( x + 1 ) ;
1414 splits ++ ;
1515 }
1616 } ) ;
@@ -27,16 +27,13 @@ export function part2(input) {
2727 let timelines = 1 ;
2828 while ( map [ curr ] ) {
2929 let next = new Map ( ) ;
30- function add ( x , count ) {
31- let c = next . get ( x ) || 0 ;
32- next . set ( x , c + count ) ;
33- }
30+ let add = ( x , count ) => next . set ( x , ( next . get ( x ) || 0 ) + count ) ;
3431 beams . forEach ( ( count , x ) => {
3532 if ( map [ curr ] [ x ] === "." ) {
3633 add ( x , count ) ;
3734 } else {
38- if ( map [ curr ] [ x - 1 ] ) add ( x - 1 , count ) ;
39- if ( map [ curr ] [ x + 1 ] ) add ( x + 1 , count ) ;
35+ add ( x - 1 , count ) ;
36+ add ( x + 1 , count ) ;
4037 timelines += count ;
4138 }
4239 } ) ;
You can’t perform that action at this time.
0 commit comments