Best shuffle: Difference between revisions
Content added Content deleted
(I am rather proud of my shuffling algorithm(s).) |
(change task desciption) |
||
Line 1: | Line 1: | ||
{{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, ( |
{{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. |
||
For example: <code>tree, eetr, (0)</code> |
For example: <code>tree, eetr, (0)</code> |
||
A shuffle that produces a randomized result is to be preferred. A deterministic approach that produces the same sequence every time is acceptable as an alternative. |
|||
The words to test with are: <code>abracadabra</code>, <code>seesaw</code>, <code>elk</code>, <code>grrrrrr</code>, <code>up</code>, <code>a</code> |
The words to test with are: <code>abracadabra</code>, <code>seesaw</code>, <code>elk</code>, <code>grrrrrr</code>, <code>up</code>, <code>a</code> |