Paste: AOC day 1

Author: chunes
Mode: factor
Date: Tue, 1 Dec 2020 11:53:52
Plain Text |
USING: fry io.encodings.ascii io.files kernel literals math
math.combinatorics math.parser prettyprint sequences ;
IN: aoc.2020.01

CONSTANT: input $[
    "resource:work/aoc/2020/01/input.txt" ascii file-lines
    [ string>number ] map
]

: find-product ( seq n target -- product )
    '[ sum _ = ] find-combination product ;

: part1 ( -- ) input 2 2020 find-product . ;
: part2 ( -- ) input 3 2020 find-product . ;  ! Part 2 runs in about 168 ms

Annotation: AOC = Advent of Code

Author: chunes
Mode: factor
Date: Wed, 2 Dec 2020 14:00:54
Plain Text |
! AOC stands for Advent of Code.
! It is a series of programming puzzles that run from
! December 1st through December 25th each year.
! See
! https://adventofcode.com and
! https://www.reddit.com/r/adventofcode/

New Annotation

Summary:
Author:
Mode:
Body: