A secret message is coded as follows. First, only the letters of the message are kept and written one next to another. This way, there are no more spaces, punctuation marks and other characters in the message; The letters from this reduced message are then first written column per column in a fixed set of columns k, and are completed with random letters, so that a rectangle grid is formed. Consequentially, the message "Always look on the bright side of life.", for example, is written as follows over 5 columns:
a o e s i l o b i f w k r d e a o i e x y n g o x s t h f x l h t l x
Note that all letters from the message were converted to lowercase letters, and that the letter x is used to make sure that the letters fit a rectangle grid of five columns (it is allowed to fill the grid with other letters). Based on the letter grid, the message is coded writing the letters next to each other in each row, alternating from left to right and from right to left. The message we used above, is coded as follows:
aoesifibolwkrdexeioayngoxxfhtslhtlx
Can you trace back the original message (including the random letters that were used as fillers in the grid) from the coded message?
Write a function decode, to which a coded message has to be passed as an argument. This coded message was encrypted using the principle described above (to-and-fro coding with a given number of columns $$k$$), which has to be given to the function as a second argument. As a result, the function has to return the deciphered message. The letters that were used as fillers for the letter grid should remain in the deciphered message.
>>> decode('aoesifibolwkrdexeioayngoxxfhtslhtlx', 5)
'alwayslookonthebrightsideoflifexxxx'
>>> decode('aohpdntilirndsnefxxftgonomceexxrloewftmyex', 6)
'andnowforsomethingcompletelydifferentxxxxx'