USING: io.encodings.utf8 io.files math math.order math.parser sequences sorting splitting ; IN: aoc.1 : input ( -- file ) "~/factor/aoc/1/1.in" utf8 file-lines ; : get-sorted-sums ( -- sums ) input { "" } split [ [ string>number ] map sum ] map natural-sort reverse ; : part1 ( -- x ) get-sorted-sums first ; : part2 ( -- x ) get-sorted-sums first3 + + ;