Paste: aoc1

Author: erg
Mode: factor
Date: Thu, 1 Dec 2022 21:32:55
Plain Text |
! Copyright (C) 2022 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: kernel math.parser math.statistics sequences splitting ;
IN: 2022-aoc1

: parse-aoc1 ( string -- seq )
    string-lines { "" } split
    [ [ string>number ] map-sum ] map ;

: aoc1-1 ( string -- n ) minmax nip ;

: aoc1-2 ( string -- n ) { 0 1 2 } kth-largests sum ;

Annotation: Ehhh

Author: erg
Mode: factor
Date: Thu, 1 Dec 2022 21:37:23
Plain Text |
! Copyright (C) 2022 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: kernel math.parser math.statistics sequences splitting ;
IN: 2022-aoc1

: parse-aoc1 ( string -- seq )
    string-lines { "" } split
    [ [ string>number ] map-sum ] map ;

: aoc1-1 ( string -- n ) parse-aoc1 minmax nip ;

: aoc1-2 ( string -- n ) parse-aoc1 { 0 1 2 } kth-largests sum ;

New Annotation

Summary:
Author:
Mode:
Body: