You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
10 lines
290 B
Racket
10 lines
290 B
Racket
4 years ago
|
#lang br
|
||
|
(require racket/file rackunit)
|
||
|
|
||
|
(define (solve combo-length)
|
||
|
(for/first ([c (in-combinations (map string->number (file->lines "01.rktd")) combo-length)]
|
||
|
#:when (eq? 2020 (apply + c)))
|
||
|
(apply * c)))
|
||
|
|
||
|
(check-equal? (solve 2) 1007331)
|
||
|
(check-equal? (solve 3) 48914340)
|