From 48ae4e67b9bc53fb3c7329142621ddef4fa8a16a Mon Sep 17 00:00:00 2001 From: Andinus Date: Sun, 6 Dec 2020 20:48:41 +0530 Subject: Add day-06 solution --- 2020/day-06/day-06.raku | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 2020/day-06/day-06.raku (limited to '2020/day-06/day-06.raku') 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; +} -- cgit 1.4.1-2-gfad0