Problem 1467. Key Generation for Solitaire Cipher
The Solitaire Cipher by Bruce Schneier was introduced to Cody in two problems by Doug Hull: http://www.mathworks.com/matlabcentral/cody/problems/753-solitaire-cipher and http://www.mathworks.com/matlabcentral/cody/problems/766-implement-solitaire-cipher-for-n-long-deck.
However, these problems do not address the initial configuration of the deck. One simple approach uses a key phrase, as described here: http://programmingpraxis.com/2011/01/18/solitaire-cipher/
Your job is to implement this key generator. Begin with the cards in numeric order (1:28) and process the deck once. (To "process" the deck you should carry out all the steps necessary to produce one character in the keystream with the regular Solitaire cipher, but you don't emit any output.) Now for each character k in the key, cut the deck by moving k cards from the front to the back of the deck. After each cut, process the deck once again. Assume that any non-alphabetic characters in the keyphrase generate a null cut (move zero characters from front to back).
At the end, you should return the state of the deck.
Solution Stats
Solution Comments
Show commentsProblem Recent Solvers6
Suggested Problems
-
Find the numeric mean of the prime numbers in a matrix.
8978 Solvers
-
Return the 3n+1 sequence for n
8336 Solvers
-
Get the area codes from a list of phone numbers
1061 Solvers
-
156 Solvers
-
Find the area of a rectangle if length of the diagonal is given.
165 Solvers
More from this Author11
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!