summary refs log tree commit diff stats
path: root/2020/day-06/day-06.raku
diff options
context:
space:
mode:
Diffstat (limited to '2020/day-06/day-06.raku')
-rwxr-xr-x2020/day-06/day-06.raku24
1 files changed, 24 insertions, 0 deletions
diff --git a/2020/day-06/day-06.raku b/2020/day-06/day-06.raku
new file mode 100755
index 0000000..24f55f4
--- /dev/null
+++ b/2020/day-06/day-06.raku
@@ -0,0 +1,24 @@
+#!/usr/bin/env raku
+
+sub MAIN (
+    Int $part where * == 1|2 = 1 #= part to run (1 or 2)
+) {
+    my $input = slurp "input";
+    my @answers = $input.chomp.split("\n\n");
+    my $count = 0;
+
+    for @answers -> $answer {
+        my %yes;
+        my @individual_answers = $answer.split("\n");
+        %yes{$_} += 1 for @individual_answers.join.comb;
+
+        if $part == 1 {
+            $count += keys %yes;
+        } elsif $part == 2 {
+            for keys %yes {
+                $count += 1 if %yes{$_} eq @individual_answers.elems;
+            }
+        }
+    }
+    say "Part $part: ", $count;
+}