From 63302f6a3e97833f104fdc8db3e4998705eed8b3 Mon Sep 17 00:00:00 2001 From: haskal Date: Sun, 6 Dec 2020 00:07:33 -0500 Subject: [PATCH] day 6: initial implementation --- 6.rkt | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 6.rkt diff --git a/6.rkt b/6.rkt new file mode 100644 index 0000000..ce78c4c --- /dev/null +++ b/6.rkt @@ -0,0 +1,31 @@ +#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"))