1
0
Fork 0
advent-of-code-2024/1-1.rb
2024-12-01 16:21:27 -05:00

14 lines
256 B
Ruby
Executable file

#!/usr/bin/env ruby
require "debug"
input = File.readlines("1.input").map(&:split)
first = input.map(&:first).compact.sort
last = input.map(&:last).compact.sort
result = first.map.with_index do |v, i|
(v.to_i - last[i].to_i).abs
end.sum
puts result