Imagine you have an infinite sequence of the alphabet repeated infinitely many times:
abcdefghijklmnopqrstuvwxyzabcd...
You start at index 0
, which corresponds to the letter a
, and the should_write
boolean flag is False
.
The input is a list or string of single-digit numbers. For each number n
in the input, you should:
Print (or add to the return value) the
n-th
item of the list if theshould_write
flag is set toTrue
If
n
is0
, swap theshould_write
flag.Otherwise move (jump) the index
n
places forward.
At the end of the input, stop (and return the result if using a function).
Input
A sequence of digits (list or string).
Output
The text that comes out after applying the above procedure.
Examples
>>> g('99010')
st
>>> g('100')
b
>>> g('2300312')
f
>>> g('390921041912042041010')
mvxyptvab
>>> g('1')
>>> g('1045')
bf
>>> g('33005780')
g
>>> g('100100102')
bcd
>>> g('012')
ab
'33005780'
, how is more than 1 char printed? Theshould_write
flag starts off, is turned on for one digit and turned back off immediately, and then only turned on again at the end. \$\endgroup\$ – xnor Oct 13 '15 at 20:39