Paste: AoC 2025 day 6

Author: annikapaprika
Mode: factor
Date: Sat, 6 Dec 2025 12:24:28
Plain Text |
USING: ascii kernel math.matrices math.parser sequences
sequences.extras splitting ;
IN: 2025.06

: parse ( word-lines -- lists operators )
    [ harvest ] map unclip-last
    [ [ dec> ] matrix-map flip ] [ [ "*" = ] map ] bi* ;

: part-1 ( lists operators -- n )
    [ [ product ] [ sum ] if ] 2map-sum ;

: parse* ( lines -- lists operators )
    unclip-last [
        flip [ [ digit? ] filter ] map { { } } split
        [ dec> ] matrix-map
    ] [ split-words harvest [ "*" = ] map ] bi* ;

New Annotation

Summary:
Author:
Mode:
Body: