You are viewing a single comment's thread. Return to all comments →
Explained Python Solution
def encryption(s): s = s.replace(" ", "") # remove spaces l = len(s) # length l_sqrt = math.sqrt(l) # take square root of length row = math.floor(l_sqrt) # take floor of square root column = math.ceil(l_sqrt) # take ceil of square root row = column if row*column < l else row # check rule es = "" # instance of encrypted sentence for x in range(column): for y in range(row): if x < l : es += s[x] # prove against IndexError x += column # upgrade index es += " " # blank between encrypted words return es
Seems like cookies are disabled on this browser, please enable them to open this website
Encryption
You are viewing a single comment's thread. Return to all comments →
Explained Python Solution