The following example illustrates how the scytale works. Assume we are working with a dowel having a diameter allowing to write four letters on the ribbon before it wraps again around the dowel. If we want to encode the message "Help me I am under attack", the entire text can be written over seven columns (of which the last three do not use one of the positions). Encoding the text comes down to writing the text from left to right, and from top to bottom on the ribbon.
--------+---+---+---+---+---+---+---+---+----
| H | e | l | p | | m | e | * |
+---| | I | | a | m | | u | * |
| * | n | d | e | r | | a | t |---+
| * | t | a | c | k | * | * | * |
----+---+---+---+---+---+---+---+---+--------
After the ribbon has been released from the dowel, the encoded message reads as "H nteIdal ecpark m m aeut". This indeed has turned the message into an incomprehensible series of letters. To decode the text, the ribbon can be wrapped again around a dowel with the same diameter, after which the original text can be read from left to right, and top to bottom.
Write a function encode that takes two arguments: i) a text that must be encoded and ii) the number of letters that fit on a single wrap of the ribbon around the dowel. The function must return a string containing the encoded message for the given text according to the scytale coding scheme. In coding the text, the minimum number of columns needed to fit the text must be used.
Write a function decode that takes two arguments: i) a text encoded according to the scytale coding scheme and ii) the number of letters that fits on a single wrap of the ribbon around the dowel. The function must return a string containing the original text after decoding.
>>> encode('Help me I am under attack', 4)
'H nteIdal ecpark m m aeut'
>>> decode('H nteIdal ecpark m m aeut', 4)
'Help me I am under attack'
>>> encode('Always look on the bright side of life.', 7)
'A o t fllnb oewo rsf.aotii ykhgdls ehei'
>>> decode('A o t fllnb oewo rsf.aotii ykhgdls ehei', 7)
'Always look on the bright side of life.'