Best shuffle: Difference between revisions

m
Line 419:
 
=={{header|Icon}} and {{header|Unicon}}==
The approach taken will run in O(n*(n-1)/2) time and swap once per changed character. The algorithm is conceptually simpler and avoids the lists of indices, sorting, cycles, groups, and special cases requiring rotation. Additionally, this can be trivially modified to randomize the shuffle.
<lang icon>procedure main(args)
while scram := bestShuffle(line := read()) do
Anonymous user