Problem 1467. Key Generation for Solitaire Cipher

The Solitaire Cipher by Bruce Schneier was introduced to Cody in two problems by Doug Hull: and

However, these problems do not address the initial configuration of the deck. One simple approach uses a key phrase, as described here:

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

60.0% Correct | 40.0% Incorrect
Last solution submitted on Sep 16, 2015
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!

Join the 15-year community celebration.

Play games and win prizes!

Learn more