Paste: AOC day 2 simple

Author: chunes
Mode: factor
Date: Thu, 2 Dec 2021 07:02:29
Plain Text |
! Not my solution. Inspired by
! https://www.reddit.com/r/adventofcode/comments/r6zd93/2021_day_2_solutions/hmwbtbe/

[let
    0 0 0 :> ( h! d! a! )
    "input.txt" ascii file-lines [
        " " split1 dec> :> n {
            { "forward" [ h n + h! d n a * + d! ] }
            { "up" [ a n - a! ] }
            [ drop a n + a! ]
        } case
    ] each
    h a * . h d * .
]

New Annotation

Summary:
Author:
Mode:
Body: