def scramble_string(s, key):
key = key_digits(key)<EOL>for k in key:          <EOL><INDENT>s = shift(s, key)  <EOL>s = s[k:] + s[:k]  <EOL>s = shuffle(s)     <EOL><DEDENT>return s<EOL>
s is the puzzle's solution in column-major order, omitting black squares:
i.e. if the puzzle is:
    C A T
    # # A
    # # R
solution is CATAR


Key is a 4-digit number in the range 1000 <= key <= 9999