diff options
author | J.J <thechairman@thechairman.info> | 2023-11-30 17:10:00 -0500 |
---|---|---|
committer | J.J <thechairman@thechairman.info> | 2023-11-30 17:10:00 -0500 |
commit | 8ab65dc2da1742eb86ec636c50c7018385b68167 (patch) | |
tree | c4fd556aca9b867cfa1f2f174128c30857353884 /aoc2020/day-06 | |
parent | fafbeaf9e3c09ba7a5bea7e47d5736001f8a5aa1 (diff) | |
download | gleam_aoc-8ab65dc2da1742eb86ec636c50c7018385b68167.tar.gz gleam_aoc-8ab65dc2da1742eb86ec636c50c7018385b68167.zip |
prep for 2023, renaming for consistency
Diffstat (limited to 'aoc2020/day-06')
-rw-r--r-- | aoc2020/day-06/day-06.rkt | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/aoc2020/day-06/day-06.rkt b/aoc2020/day-06/day-06.rkt new file mode 100644 index 0000000..b0e2af9 --- /dev/null +++ b/aoc2020/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 |