14 lines
324 B
Ruby
14 lines
324 B
Ruby
#!/bin/env ruby
|
|
|
|
ids = File.readlines('./input').map(&:strip)
|
|
checksum = {twos: 0, threes: 0}
|
|
|
|
ids.map! { |id| id.each_char.tally.delete_if { |char, count| count==1 }}
|
|
ids.each do |id|
|
|
checksum[:twos] += 1 if id.has_value?(2)
|
|
checksum[:threes] += 1 if id.has_value?(3)
|
|
end
|
|
|
|
puts checksum[:twos] * checksum[:threes]
|
|
|