Paste: AOC Day 2

Author: Kacarott
Mode: factor
Date: Fri, 2 Dec 2022 17:18:55
Plain Text |
! Copyright (C) 2022 Keldan Chapman.
! See http://factorcode.org/license.txt for BSD license.
USING: kernel AOC prettyprint splitting sequences ;
IN: AOC.2022.2

CONSTANT: points1 { f "B X" "C Y" "A Z" "A X" "B Y" "C Z" "C X" "A Y" "B Z" }
CONSTANT: points2 { f "B X" "C X" "A X" "A Y" "B Y" "C Y" "C Z" "A Z" "B Z" }

: count-points ( input points -- result )
    [ "\n" split harvest ] dip [ index ] curry map-sum ;

: part-1 ( input -- result ) points1 count-points ;
: part-2 ( input -- result ) points2 count-points ;

MAIN: [ 2 read-day-input [ part-1 . ] [ part-2 . ] bi ]

New Annotation

Summary:
Author:
Mode:
Body: