finished solution 2

master
Jeff Yates 2020-12-08 10:15:46 -05:00
parent 10794e411f
commit 7c1f6ae89c
1 changed files with 17 additions and 0 deletions

17
day06/solution02.rb Executable file
View File

@ -0,0 +1,17 @@
#!/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