AoC2020/day06/solution02.rb

17 lines
347 B
Ruby
Executable File

#!/bin/env ruby
groups = Hash.new
text = File.read('./input').strip.split("\n\n")
people = text.map { |t| t.count("\n") + 1 }
text.map!.with_index do |t, i|
t.delete!("\n")
t.each_char { |c| t.delete!(c) if t.count(c) != people[i] }
t.split('').uniq.reduce(:+)
end
text.compact!
size = text.map { |t| t.length }.reduce(:+)
p size