! 2022 nomennescio USING: io.encodings.utf8 io.files kernel math.intervals math.parser prettyprint sequences splitting ; IN: aoc2022 : parse-file ( path encoding -- pairs ) file-lines [ "," split [ "-" split [ dec> ] map first2 [a,b] ] map ] map ; : part1 ( -- ) "input-4.txt" utf8 parse-file [ first2 [ interval-subset? ] [ swap interval-subset? ] 2bi or ] count . ; : part2 ( -- ) "input-4.txt" utf8 parse-file [ first2 intervals-intersect? ] count . ; : day4 ( -- ) part1 part2 ; MAIN: day4