USING: io.encodings.utf8 splitting math.parser sequences ; : input ( -- contents ) "/tmp/aoc1.txt" utf8 file-contents ; : greatest-calories ( contents -- n ) "\n\n" split [ empty? ] split-when [ 0 [ dec> + ] reduce ] [ max ] map-reduce ; : main ( -- n ) input greatest-calories ;