m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/06/a.rb
blob: 2dd7de39abfbb011dfb280c37521d0ea9bbb7abd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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