• + 0 comments

    Python 3

    def encryption(s):
        s = s.replace(" ","")
        length = len(s)
        columns = math.ceil(length**0.5)
        encrypted_s = ["" for i in range(columns)]
        for i in range(length):
            encrypted_s[i%columns] += s[i]
        return " ".join(encrypted_s)