m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/10/a.rb
blob: 34336ef1908cc6c6e6f6d3c3f171b71d3761e998 (plain)
1
2
3
4
5
6
7
8
9
10
lines = File.readlines('input.txt').map { |l| l.to_i }
lines.sort!
lines.unshift(0)
lines.push(lines.last + 3)
diffs = Hash.new 0
lines.each_cons 2 do |chargers|
  diffs[chargers[1]  - chargers[0]] += 1
end

puts diffs[1] * diffs[3]