aoc2020/1.rkt

15 lines
345 B
Racket
Raw Normal View History

2020-12-01 21:34:16 +00:00
#lang racket
;; solution for day 1
(module+ main
(define nums (map string->number (file->lines "inputs/1")))
;; part 1
(for*/first ([a (in-list nums)] [b (in-list nums)] #:when (= 2020 (+ a b)))
(* a b))
;; part 2
(for*/first ([a (in-list nums)] [b (in-list nums)] [c (in-list nums)] #:when (= 2020 (+ a b c)))
(* a b c)))