Minimum Spanning Tree by shinh

m={}
$<.sort_by{|a|a[4,9].hex}.map{|z|c,d=z.split.map{|i|m[i]||[i]}
puts (d==(c|=d)?'F ':'T ')+z
c.map{|i|m[i]=c}}

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return top