Paste: AoC (Capital)

Author: CapitalEx
Mode: factor
Date: Fri, 2 Dec 2022 01:03:09
Plain Text |
USING: io.backend io.encodings.utf8 io.files kernel math.parser
sequences sorting splitting ;
IN: advent-of-code.day-01

: get-input-one ( -- file )
    "vocab:advent-of-code/day-01/_input/one.txt" 
        normalize-path utf8 file-lines ;

: compute-sums ( seq -- seq )
    [ dec> ] map [ not ] split-when [ sum ] map ;

: solve-problem-one ( -- solution )
    get-input-one compute-sums supremum ;

: last3 ( seq -- seq )
    3 tail* ;

: solution-problem-two ( -- solution ) 
   get-input-one compute-sums natural-sort last3 sum ;

New Annotation

Summary:
Author:
Mode:
Body: