Levenshtein Distance Sort FIXED by I., S.(faster)

import Data.List
z=zipWith
main=interact$unlines.u.lines
u w@(h:t)=map snd.sort$zip(zip[h!e|e<-w][0..])w
x!y=last$foldl(#)[0..][1:map(fromEnum.(/=r))x|r<-y]
d#q=scanl1(%)$z(%)d$z(+)(99:d)q
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