RosettaCodeData/Task/Best-shuffle/00-TASK.txt
2023-07-01 13:44:08 -04:00

32 lines
700 B
Text

;Task:
Shuffle the characters of a string in such a way that as many of the character values are in a different position as possible.
A shuffle that produces a randomized result among the best choices is to be preferred. A deterministic approach that produces the same sequence every time is acceptable as an alternative.
Display the result as follows:
original string, shuffled string, (score)
The score gives the number of positions whose character value did ''not'' change.
;Example:
tree, eetr, (0)
;Test cases:
abracadabra
seesaw
elk
grrrrrr
up
a
;Related tasks
*   [[Anagrams/Deranged anagrams]]
*   [[Permutations/Derangements]]
{{Template:Strings}}
<br><br>