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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
aoc-racket/2020/06.rkt

14 lines
411 B
Racket

#lang br
(require racket/file racket/set rackunit)
(define (solve set-proc)
(for/sum ([group (string-split (file->string "06.rktd") #px"\n\n+")])
(set-count (apply set-proc (for/list ([person (string-split group "\n")])
(for/seteqv ([c person])
c))))))
(check-equal? (solve set-union) 6549)
(check-equal? (solve set-intersect) 3466)