From ae26a072fb9d90ad27238ea75004166d17521ed0 Mon Sep 17 00:00:00 2001 From: Marcin Chrzanowski Date: Fri, 25 Dec 2020 15:19:04 +0100 Subject: Add day 6 --- 06/a.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 06/a.rb (limited to '06/a.rb') diff --git a/06/a.rb b/06/a.rb new file mode 100644 index 0000000..2dd7de3 --- /dev/null +++ b/06/a.rb @@ -0,0 +1,16 @@ +groups = File.read('input.txt').split("\n\n") + +total = groups.reduce(0) do |total, group| + answers = group.split("\n") + + anyone = answers.reduce(Hash.new false) do |anyone, answer| + answer.each_char do |c| + anyone[c] = true + end + anyone + end + subtotal = anyone.size + total + subtotal +end + +puts total -- cgit v1.2.3