diff options
author | Marcin Chrzanowski <marcin.j.chrzanowski@gmail.com> | 2020-12-25 15:19:04 +0100 |
---|---|---|
committer | Marcin Chrzanowski <marcin.j.chrzanowski@gmail.com> | 2020-12-25 15:19:04 +0100 |
commit | ae26a072fb9d90ad27238ea75004166d17521ed0 (patch) | |
tree | 6dca3268466cfc60955304851ef9978d1ff4b768 /06/a.rb | |
parent | 8ef384f47d69ce346a523cc76f334b89712e8cab (diff) |
Add day 6
Diffstat (limited to '06/a.rb')
-rw-r--r-- | 06/a.rb | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -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 |