parent
7044bcdc23
commit
536f505093
1 changed files with 13 additions and 0 deletions
@ -0,0 +1,13 @@ |
||||
#!/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] |
||||
|
Loading…
Reference in new issue