Paste: AoC 2021 1-2

Author: nomennescio
Mode: factor
Date: Sat, 4 Dec 2021 23:11:57
Plain Text |
! 2021 nomennescio
USING: kernel io io.files io.encodings.utf8 math math.parser math.vectors prettyprint sequences  sequences.windowed ;
IN: aoc2021

: file-numbers ( path encoding -- numbers ) file-lines [ string>number ] map ;
: deltas ( numbers -- deltas ) [ 0 suffix ] [ 0 prefix ] bi v- rest ;
: #increases ( numbers -- n ) deltas [ 0 > ] count ;
: threesum ( numbers -- threesum ) 0 suffix 3 rolling-sum 3 tail ;
: 1-2 ( -- ) "input.1-1.txt" utf8 file-numbers threesum #increases . ; 

MAIN: 1-2

New Annotation

Summary:
Author:
Mode:
Body: