In Rail Fence Cipher encoding is done by placing each character successively in a diagonal along with a set of rails.
Create a function that takes two arguments; a string and the number of rails, and returns the encoded message.
message = "WEAREDISCOVEREDFLEEATONCE"
rails = 3
rail_fence_cipher(message, rails) ➞ "WECRLTEERDSOEEFEAOCAIVDEN"In the above example, the given message to be decomposed in 3 rails:
W E C R L T E
E R D S O E E F E A O C
A I V D E NStarting from the upper line, the encoded message will be:
"WECRLTEERDSOEEFEAOCAIVDEN"rail_fence_cipher("WEAREDISCOVEREDFLEEATONCE", 3) ➞ "WECRLTEERDSOEEFEAOCAIVDEN"
rail_fence_cipher("EDABITISAMAZING", 4) ➞ "EIIDTSZNAIAAGBM"
rail_fence_cipher("WEWILLALLDIEONEDAY", 3) ➞ "WLLOAEILLDENDYWAIE"Rails will be >=2