git.alexw.nyc home about git garden
    1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
10 const w
w dup * const sz
f" /aoc/test"

create schematic sz allot0
: readschematic ( -- ) schematic file :readall ;
: symbol ( c -- f ) dup 0-9? swap '.' = or not ;

: symbol-adj ( x y -- f ) ;

0 value total 
: symboln ( -- ) ;
: solve readschematic
0 >r
begin to1+ V1
schematic V1 + dup c@ 0-9? if 
\ parse num
symbol-adj
else drop then 
V1 sz = until
schematic sz rfor i c@ 0-9? if then
solve