Paste: AOC day 10

Author: chunes
Mode: factor
Date: Sun, 13 Dec 2020 06:08:44
Plain Text |
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 . ;

New Annotation

Summary:
Author:
Mode:
Body: