diff options
author | Hunky Jimpjorps <thechairman@thechairman.info> | 2022-11-28 22:50:22 -0500 |
---|---|---|
committer | Hunky Jimpjorps <thechairman@thechairman.info> | 2022-11-28 22:50:22 -0500 |
commit | c871d9cbe4cc6d3063665a428de4b205cef29041 (patch) | |
tree | 7a1ad52aaea5a551ce57e546e53fb044a69b9af3 /2020/day-06/day-06.rkt | |
parent | feccf3f6f0a806b3317d1f399e3e8b42945c4f09 (diff) | |
download | gleam_aoc-c871d9cbe4cc6d3063665a428de4b205cef29041.tar.gz gleam_aoc-c871d9cbe4cc6d3063665a428de4b205cef29041.zip |
2020: day 4, 6, 7
Diffstat (limited to '2020/day-06/day-06.rkt')
-rw-r--r-- | 2020/day-06/day-06.rkt | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/2020/day-06/day-06.rkt b/2020/day-06/day-06.rkt new file mode 100644 index 0000000..b0e2af9 --- /dev/null +++ b/2020/day-06/day-06.rkt @@ -0,0 +1,22 @@ +#lang racket +(require "../../jj-aoc.rkt" + threading) + +(define responses (~> (open-day 6 2020) (port->string) (string-split "\n\n"))) + +;; part 1 +(define (response-count-total rs) + (for/sum ([r (in-list rs)]) (~> r (string-replace _ "\n" "") string->list list->set set-count))) + +(response-count-total responses) + +;; part 2 +(define (response-consensus-total rs) + (for/sum ([r (in-list rs)]) + (~> r + (string-split _ "\n") + (map (λ~> string->list list->set) _) + (apply set-intersect _) + set-count))) + +(response-consensus-total responses)
\ No newline at end of file |