Minimum Spanning Tree by murky-satyr

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

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

download

return to the top page