solved part 1
parent
7044bcdc23
commit
536f505093
|
@ -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