diff options
Diffstat (limited to '06/b.rb')
-rw-r--r-- | 06/b.rb | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -0,0 +1,19 @@ +groups = File.read('input.txt').split("\n\n") + +total = groups.reduce(0) do |total, group| + answers = group.split("\n") + + all = answers.reduce(Hash.new true) do |all, answer| + new_all = {} + answer.each_char do |c| + if all[c] + new_all[c] = true + end + end + new_all + end + subtotal = all.size + total + subtotal +end + +puts total |