Author: | chunes |
---|---|
Mode: | factor |
Date: | Mon, 6 Dec 2021 06:51:35 |
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 .