14 lines
256 B
Ruby
Executable file
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
|