You come upon a very unusual sight; a group of programs here appear to be dancing.
There are sixteen programs in total, named
p. They start by standing in a line: a stands in position
b stands in position
1, and so on until
p, which stands in position
The programs' dance consists of a sequence of dance moves:
- Spin, written
Xprograms move from the end to the front, but maintain their order otherwise. (For example,
- Exchange, written
xA/B, makes the programs at positions
- Partner, written
pA/B, makes the programs named
For example, with only five programs standing in a line (
abcde), they could do the following dance:
s1, a spin of size 1:
x3/4, swapping the last two programs:
pe/b, swapping programs
baedc. After finishing their dance, the programs end up in order
You watch the dance for a while and record their dance moves (your puzzle input). Write a program that outputs the program's final positions after the dance.
Example input: abcdefghijklmnop Example output: ponmlkjihgfedcba
Input file can be copied from here.
- Submissions must be sent to firstname.lastname@example.org with the subject "WBC Coding Challenge 3" and have the program attached.
- Submissions received MUST come be from a Western email (ending in @wwu.edu).
- Submissions will be tested with the input file ("WBC_CodingChallenge3_Input.txt") in the same directory as the submitted program.
- Submissions must be able run without arguments (all file opening and reading must happen in the program).
- Allowed programming languages: Java, Python, C/C#/C++.
- Individual and group participation is welcome (only one gift card will be awarded to winning submission).
This problem was created by Eric Wastl, link to his portfolio page http://was.tl/.