Paste: aoc 10
Author: | Kren/chunes |
Mode: | factor |
Date: | Sat, 10 Dec 2022 09:52:49 |
Plain Text |
USING: assocs grouping io io.encodings.ascii io.files kernel
literals math math.functions math.parser math.statistics
math.vectors pair-rocket prettyprint sequences splitting.extras ;
IN: aoc2022.day10
CONSTANT: input $[
"vocab:aoc2022/day10/input.txt" ascii file-contents
"\n " split-harvest
{ "noop" => "0" "addx" => "0" } substitute
[ dec> ] map 1 prefix cum-sum
]
: part1 ( -- )
{ 20 60 100 140 180 220 } dup 1 v-n input nths vdot . ;
: part2 ( -- )
input 240 <iota> [ 40 mod - [-1,1]? 35 46 ? ] 2map 40 group
[ print ] each ;
: day10 ( -- ) part1 part2 ;
MAIN: day10
New Annotation