Paste: AOC day 5 clever
Author: | chunes |
Mode: | factor |
Date: | Sat, 5 Dec 2020 13:52:51 |
Plain Text |
USING: io.encodings.ascii io.files kernel literals math.order
math.parser math.ranges math.statistics multiline peg.ebnf
prettyprint sequences sets ;
IN: aoc.2020.05clever
CONSTANT: input
$[ "resource:work/aoc/2020/05/input.txt" ascii file-lines ]
EBNF: id [=[
zero = [FL] => [[ drop CHAR: 0 ]]
one = [BR] => [[ drop CHAR: 1 ]]
bin = (zero|one)+ => [[ bin> ]]
]=]
: part1 ( -- ) input [ id ] [ max ] map-reduce . ;
: part2 ( -- )
input [ id ] map dup minmax [a,b] swap diff first . ;
New Annotation