# Task
 A common way for prisoners to communicate secret messages with each other is to encrypt them. One such encryption algorithm goes as follows.

 You take the message and place it inside an `nx6` matrix (adjust the number of rows depending on the message length) going from top left to bottom right (one row at a time) while replacing spaces with dots (.) and adding dots at the end of the last row (if necessary) to complete the matrix.
 
 Once the message is in the matrix you read again from top left to bottom right but this time going one column at a time and treating each column as one word.

# Example

 The following message `"Attack at noon or we are done for"` is placed in a `6 * 6` matrix :
```
Attack
.at.no
on.or.
we.are
.done.
for...```
Reading it one column at a time we get:

 `A.ow.f tanedo tt..or a.oan. cnrre. ko.e..`

# Input/Output


 - `[input]` string `msg`

  a regular english sentance representing the original message


 - `[output]` a string

  encrypted message

Difficulty: introductory

Starter code:

def six_column_encryption(msg):
	

Solutions:
def six_column_encryption(msg):
    msg=msg.replace(' ','.')+'.'*((6-len(msg)%6)%6)
    return ' '.join(msg[n::6] for n in range(6))

from itertools import zip_longest

def six_column_encryption(msg, size=6):
    msg = msg.replace(' ','.')
    L = [msg[i:i+size] for i in range(0, len(msg), size)]
    return ' '.join(map(''.join, zip_longest(*L, fillvalue='.')))

from itertools import zip_longest

def six_column_encryption(msg):
    return ' '.join(map(''.join,
        zip_longest(*(msg[i:i+6].replace(' ', '.') for i in range(0, len(msg), 6)), fillvalue='.')
    ))

def six_column_encryption(msg):
    row = (len(msg) + 5) // 6
    gen = iter(msg.replace(" ", "."))
    arr = zip(*[[next(gen, ".") for i in range(6)] for j in range(row)])
    return " ".join("".join(line) for line in arr)

six_column_encryption=lambda s:' '.join(map(''.join,zip(*zip(*[iter(s.replace(' ','.')+'.'*5)]*6))))

def six_column_encryption(msg):
    msg = msg.replace(" ", ".") + "." * (6 - len(msg) % 6 if len(msg) % 6 != 0 else 0)
    return " ".join([msg[i::6] for i in range(6)])

from math import ceil
def six_column_encryption(msg):
    n=ceil(len(msg)/6)
    s=(msg+' '*(n*6-len(msg))).replace(' ','.')
    r=[]
    for i in range(6):
        r.append(s[i::6])
    return ' '.join(r)

def six_column_encryption(msg):
    msg, ans = msg.replace(' ', '.'), []
    
    while len(msg) % 6 != 0:
        msg += '.'
    
    r = len(msg) // 6
    
    for i in range(0, len(msg)//r):
        ans.append(''.join([msg[j] for j in range(i, len(msg), 6)]))

    return ' '.join(ans)

def six_column_encryption(msg):
    m = msg.replace(' ', '.')
    lst = [m[i:i+6] for i in range(0, len(m), 6)]
    lst[-1] = lst[-1].ljust(6, '.')
    ans = []
    for i in range(6):
        s = ''
        for j in lst:
            s += j[i]
        ans.append(s)
    return ' '.join(ans)

import numpy as np

def six_column_encryption(s):
    s = s.replace(' ','.') + '.'*(int(6*np.ceil(len(s)/6)-len(s)))
    s = [list(s[i:i+6]) for i in range(0,len(s),6)]
    arr = np.array(s).reshape(-1,6).T
    return ' '.join(map(''.join, arr))