Best shuffle: Difference between revisions

(Updated first D entry)
Line 2,352:
===Swap if it is locally better algorithm===
With added randomization of swaps!
<lang python>from collections import Counterrandom
import random
 
def count(w1,wnew):
Line 2,369 ⟶ 2,368:
if i != j and wnew[j] != wnew[i] and w[i] != wnew[j] and w[j] != wnew[i]:
wnew[j], wnew[i] = wnew[i], wnew[j]
break
wnew = ''.join(wnew)
return wnew, count(w, wnew)
Anonymous user