Paste: AOC day 6

Author: chunes
Mode: factor
Date: Mon, 6 Dec 2021 06:51:35
Plain Text |
CONSTANT: lanternfish $[
    "input.txt" ascii file-lines first "," split [ dec> ] map
    9 0 <array> tuck [ [ 1 + ] change-nth ] curry each
]

: tick ( seq -- )
    dup 1 rotate! 8 over nth '[ _ + ] 6 -rot change-nth ;

: simulate ( m seq -- n ) [ dup tick ] repeat sum ;

80 lanternfish simulate .
256 lanternfish simulate .

New Annotation

Summary:
Author:
Mode:
Body: