Levenshtein Distance Sort FIXED by I., S.(+henkma)

z=zipWith
main=interact$f.lines
f x=unlines[y|n<-[0..24],y<-x,n==x!!0!y]
x!y=last$foldl(#)[0..][1:[sum[1|s/=t]|t<-y]|s<-x]
x#y=scanl1(%)$z(%)x$z(+)y$4:x
x%y=min(1+x)y

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

download

return to the top page