Paste: aoc 4
Author: | Kren/chunes |
Mode: | factor |
Date: | Sun, 4 Dec 2022 05:15:29 |
Plain Text |
USING: arrays io.encodings.ascii io.files kernel literals
math.intervals math.parser prettyprint sequences splitting ;
IN: aoc2022.day04
CONSTANT: input $[
"vocab:aoc2022/day04/input.txt" ascii file-lines
[ "," split1 [ "-" split1 [ dec> ] bi@ [a,b] ] bi@ 2array ]
map
]
: part1 ( -- )
input [ [ first2 interval-intersect ] keep member? ] count . ;
: part2 ( -- )
input [ first2 intervals-intersect? ] count . ;
: day04 ( -- ) part1 part2 ;
MAIN: day04
New Annotation