15 lines
256 B
Ruby
15 lines
256 B
Ruby
|
#!/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
|