Paste: aoc day 11 part 1
Author: | Krenium |
Mode: | factor |
Date: | Tue, 11 Dec 2018 07:24:36 |
Plain Text |
: power-level ( x y serial# -- n )
[ 10 + dup ] 2dip [ * ] dip + * [ 10 /mod drop ] twice 10
mod 5 - ;
:: 3x3-power ( x y serial# -- n )
0 x y [ dup 2 + [a,b] ] bi@ [ serial# power-level + ]
cartesian-each ;
:: power-table ( serial# -- assoc )
298 [1,b] dup [
[ 2dup serial# 3x3-power [ 2array ] dip swap ,, ]
cartesian-each
] H{ } make ;
: part1 ( -- )
6042
power-table >alist [ second ] supremum-by first . ;
New Annotation