Paste: AoC 2021 2-1

Author: nomennescio
Mode: factor
Date: Sun, 5 Dec 2021 20:00:48
Plain Text |
! 2021 nomennescio
USING: kernel io io.files io.encodings.utf8 math math.parser math.vectors namespaces prettyprint sequences  sequences.windowed splitting words ;
IN: aoc2021

SYMBOL: hpos
SYMBOL: depth

: forward ( n -- ) hpos +@ ;
: down ( n -- ) depth +@ ;
: up ( n -- ) neg down ;

: run ( lines -- ) [ " " split1 [ "aoc2021" lookup-word ] [ dec> ] bi* swap execute( n -- ) ] each ;
: reset ( var -- ) 0 swap set ;

: 2-1 ( -- )
  hpos depth [ reset ] bi@
  "input.2-1.txt" utf8 file-lines run
  hpos depth [ get ] bi@ * . ; 

MAIN: 2-1

New Annotation

Summary:
Author:
Mode:
Body: