Paste: AoC day 1

Author: Krenium/chunes
Mode: factor
Date: Thu, 1 Dec 2022 06:04:36
Plain Text |
USING: io.encodings.ascii io.files kernel math.parser
math.statistics prettyprint sequences splitting ;

"input.txt" ascii file-lines          ! Read the input file as a sequence of lines.
[ dec> ] map { f } split [ sum ] map  ! Parse as a list of total calories for each elf.
{ 0 1 2 } kth-largests                ! Find the three largest. More efficient than sorting.
[ first . ]                           ! The largest; part 1.
[ sum . ] bi                          ! Sum of the three largest; part 2.

New Annotation

Summary:
Author:
Mode:
Body: