Extraction IV: Dancing Spy Steps
The spy has upgraded the cipher. Instead of using a constant step, the message is hidden with a sequence of steps. After each character, you move by a new number of positions — like dancing through the noise. Update the parameter step: list[int] | int
Take a character, then move by the first step. Take the next character, move by the second step, and so on. Stop when you either run out of steps or leave the string bounds. No cycling: once the steps list ends, decoding stops.
Take into consideration that you script should be able to solve all the previous missions in the series as well.
Input: Four arguments. String (str), list of positive integers or single positive integer (int), non-negative integer, boolean value (bool).
Output: String.
Examples:
assert (
extraction("x_a0b1c2d3e4f5g6h7i8j9", [1, 3, 2, 4, 5, 1, 3, 2, 4], 0, False)
== "x_bce6h89"
)
assert extraction("w!ozlzleqxeh??", [1, 4, 2, 2, 1], 2, True) == "hello!"
assert (
extraction("!!sxeccrreettmmssaaggee!!", [2, 1, 3, 2, 1, 3, 1, 4], 2, False)
== "secretmsg"
)
Preconditions:
- step(s) > 0;
- start >= 0.