m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/06/a.rb
diff options
context:
space:
mode:
Diffstat (limited to '06/a.rb')
-rw-r--r--06/a.rb16
1 files changed, 16 insertions, 0 deletions
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