Paste: AoC Day 1
Author: | Kyoko Tomato |
Mode: | factor |
Date: | Fri, 2 Dec 2022 00:01:06 |
Plain Text |
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 ;
Author: | Kyoko Tomato |
Mode: | factor |
Date: | Fri, 2 Dec 2022 00:18:35 |
Plain Text |
USING: io.encodings.utf8 splitting math.parser sequences ;
IN: aoc1
: input ( -- contents ) "/tmp/aoc1.txt" utf8 file-contents ;
: greatest-calories ( contents -- n )
"\n" split [ empty? ] split-when
[ [ dec> ] map sum ] map supremum ;
: main ( -- n )
input greatest-calories ;
New Annotation