Best shuffle: Difference between revisions

m
added a ;Task: (bold) header, added other whitespace and highlighting to the task's preamble.
m (added a ;Task: (bold) header, added other whitespace and highlighting to the task's preamble.)
Line 1:
{{task}}
{{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. Print the result as follows: original string, shuffled string, (score). The score gives the number of positions whose character value did ''not'' change.
 
;Task:
For example: <code>tree, eetr, (0)</code>
{{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. Print the result as follows: original string, shuffled string, (score). The score gives the number of positions whose character value did ''not'' change.
 
Print the result as follows: original string, shuffled string, (score).
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.
 
The &nbsp; ''score'' &nbsp; gives the number of positions whose character value did &nbsp; ''not'' &nbsp; change.
The words to test with are: <code>abracadabra</code>, <code>seesaw</code>, <code>elk</code>, <code>grrrrrr</code>, <code>up</code>, <code>a</code>
 
 
;Example:
tree ───► eetr [a &nbsp; ''score'' &nbsp; of &nbsp; '''0''' &nbsp; (zero)]
 
A shuffle that produces a randomized result among the best choices is to be preferred.
 
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.
 
 
;Test cases:
abracadabra
seesaw
elk
grrrrrr
up
a
 
 
;Related tasks
* &nbsp; [[Anagrams/Deranged anagrams]]
* &nbsp; [[Permutations/Derangements]]
<br><br>