14 lines
233 B
Ruby
14 lines
233 B
Ruby
|
lines = ARGF.read.split "\n"
|
||
|
graph = Hash.new { |h, k| h[k] = [] }
|
||
|
|
||
|
# parse input and build graph
|
||
|
lines.each do |line|
|
||
|
line.match /(\w+) to (\w+) = (\d+)/ do |m|
|
||
|
graph[m[1]] << [m[2], m[3].to_i]
|
||
|
end
|
||
|
end
|
||
|
|
||
|
puts graph.inspect
|
||
|
|
||
|
|