A riffle shuffle is a way of shuffling cards where the deck is split into 2 roughly equal sections and the sections are riffled into each other in small groups. This is how to riffle shuffle a string:
- Split the string into equal sections.
- Reverse the strings, and starting from the start of each string.
- Put runs of a uniformly random length between 1 and the number of characters left in the current string into the final string
- Then remove these characters from the string.
- Repeat for the other half, until both halves are empty.
An example
"Hello World!" Output string = ""
"Hello ", "World!" ""
"Hell", "World!" " o"
"Hell", "World" " o!"
"Hel", "World" " o!l"
"Hel", "Wo" " o!ldlr"
"H", "Wo" " o!ldlrle"
"H", "" " o!ldlrleoW"
"", "" " o!ldlrleoWH"
The final product from Hello World!
could be o!ldlrleoWH
and that is what you would output.
Cops
Your task is to make a program (or function) that will riffle shuffle a string. If the inputted string is of odd length, just split it into two uneven length strings with a relative length of +1
and +0
(abc => [ab, c] or [a, bc]
). You may take input in the normal fashion and produce output in the normal fashion.
Your Cops submission will consist of 4 things
- The language you used
- The length of your program in bytes
- Your program, riffle shuffled.
- Anything else you want to add
You are aiming to keep your code from being uncracked by the Robbers for 7 days. After that period, your program is safe and you should edit in your original program. Your submission may still be cracked until you reveal your solution. The shortest, safe solution will be the winner!