~aw/dusk-aoc

c8b449d0270c90e39e61e696e0fed5dce64bb40e — alex wennerberg 8 months ago 9dacdab main
day 15 part 1
1 files changed, 13 insertions(+), 0 deletions(-)

A 2023/15a.fs
A 2023/15a.fs => 2023/15a.fs +13 -0
@@ 0,0 1,13 @@
f<< /comp/tok.fs

: HASH ( a u -- ) 0 rot> rfor i c@ + 17 * 256 mod next ;

: _?tok< ( -- tok-or-0 )
  in< dup EOF = if drop 0 exit then \ EOF
  newtok
  begin dup ',' <> over ws? not and? while tokacc in< repeat drop curtok ;

: steptok$ tok$ ['] _?tok< ['] (?tok<) realias ; 
: _ 0 begin ?tok< ?dup while c@+ HASH + repeat ;
: solve file$ steptok$ ['] _ f" /aoc/input" file :exec< ;
solve . nl>