-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathEncryption.py
47 lines (35 loc) · 918 Bytes
/
Encryption.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/python3
import math
import os
import random
import re
import sys
#
# Complete the 'encryption' function below.
#
# The function is expected to return a STRING.
# The function accepts STRING s as parameter.
#
import math
def encryption(s):
# Write your code here
strippedString = ''.join(s.split(' '))
length = len(strippedString)
x = math.sqrt(length)
columns = math.ceil(x)
# no use of rows in this solution
# rows = math.floor(x)
# if rows*columns<len(strippedString):
# rows = columns
resultString = ''
for i in range(0,columns):
for j in range(i,length,columns):
resultString += strippedString[j]
resultString += '\t'
return resultString
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
s = input()
result = encryption(s)
fptr.write(result + '\n')
fptr.close()