We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
def encryption(s):
arr=[]
answerarray=[]
rows=math.floor(math.sqrt(len(s)))
cols=math.ceil(math.sqrt(len(s)))
if rows*cols<len(s):
rows=cols
for j in range(rows):
arr.append(s[cols*j:(cols*j)+cols])
for x in range(cols):
string=""
for y in range(rows):
** if x<len(arr[y]):**
string+=arr[y][x]
answerarray.append(string+" ")
return "".join(answerarray)
Cookie support is required to access HackerRank
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 →