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.
14 lines
411 B
Racket
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)
|
|
|