1
0
Fork 0
factor-puzzles/aoc2020/day1/day1.factor

16 lines
540 B
Factor
Raw Normal View History

2020-11-29 08:22:10 +01:00
! Copyright (C) 2020 Bubbler.
! See http://factorcode.org/license.txt for BSD license.
USING: io io.encodings.utf8 io.files kernel math.combinatorics
math.parser prettyprint sequences splitting ;
IN: aoc2020.day1
: day1-silver ( seq -- prod )
2 all-combinations [ sum 2020 = ] find nip product ;
: day1-gold ( seq -- prod )
3 all-combinations [ sum 2020 = ] find nip product ;
: day1-main ( -- ) "datasets/aoc2020/day1.txt" utf8 file-contents "\n" split [ string>number ] map
[ day1-silver . ] [ day1-gold . ] bi ;
MAIN: day1-main