solved part 1

master
s00ner 9 months ago
parent 7044bcdc23
commit 536f505093
  1. 13
      day02/solution.rb

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