MaxMinSwap by hallvabo

while 1:
 _=input();a=_[:];b=sorted(_)
 for e in b:x,y=map(a.index,(e,b.pop()));a[x]=a[y]=_[x],_[y]=_[y],e
 print`_`.replace(' ','')

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

download

return to the top page