Minimum Spanning Tree by flagitious

n=[]
puts$<.sort_by{|$_|split[2].to_i}.map{|$_|a,b=split.map{|q|n.find{|s|s&[q]!=[]}||[q]}
n=[a|b]+n
(a!=b ?'T ':'F ')+$_}

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

download

return to the top page