finished solution 2

master
Jeff Yates 2 years ago
parent 10794e411f
commit 7c1f6ae89c
  1. 17
      day06/solution02.rb

@ -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
Loading…
Cancel
Save