USING: assocs grouping io.encodings.ascii io.files kernel literals math math.combinatorics math.parser math.ranges math.statistics prettyprint sequences sets ; IN: aoc.2020.09 << CONSTANT: input $[ "input.txt" ascii file-lines [ dec> ] map ] >> << CONSTANT: part1 $[ input dup 25 tail swap 25 but-last-slice zip [ 2 [ sum ] map-combinations member? not ] assoc-find 2drop ] >> CONSTANT: input2 $[ input ${ part1 } without ] : find-range ( n -- seq ) input2 swap [ sum part1 = ] find nip ; : part2 ( -- ) input2 length [1,b] [ find-range ] find nip find-range minmax + . ;