32 lines
817 B
Racket
32 lines
817 B
Racket
#lang curly-fn racket
|
|
|
|
(require "scripts/aoc.rkt")
|
|
|
|
;; solution for day 6
|
|
|
|
;; helper functions here
|
|
|
|
(define (part1 input)
|
|
(for/sum ([grp (in-list input)])
|
|
(set-count (for/fold ([s (set)]) ([person (in-list grp)])
|
|
(set-union s person)))))
|
|
|
|
(define (part2 input)
|
|
(for/sum ([grp (in-list input)])
|
|
(set-count (for/fold ([s (list->set (string->list "abcdefghijklmnopqrstuvwxyz"))])
|
|
([person (in-list grp)])
|
|
(set-intersect s person)))))
|
|
|
|
(module+ main
|
|
(define input
|
|
(for/list ([grp (in-list (string-split (file->string "inputs/6") "\n\n"))])
|
|
(for/list ([line (in-list (string-split grp))])
|
|
(list->set (string->list line)))))
|
|
;; part 1
|
|
(answer 6 1 (part1 input))
|
|
|
|
;; part 2
|
|
(answer 6 2 (part2 input))
|
|
|
|
(displayln "meow"))
|