USING: assocs io.encodings.ascii io.files kernel literals math math.parser math.statistics prettyprint sequences sequences.extras sorting splitting.monotonic ; IN: aoc.2020.10 CONSTANT: input $[ "input.txt" ascii file-lines [ dec> ] map natural-sort dup supremum 3 + suffix 0 prefix ] : part1 ( -- ) input differences histogram values product . ; : part2 ( -- ) input [ - abs 1 = ] monotonic-split [ length { 1 1 1 2 4 7 } nth ] map-product . ;