Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/python3
- import math
- import os
- import random
- import re
- import sys
- # Complete the encryption function below.
- def encryption(s):
- #word = input("please enter a word\n")
- word = s
- word = ''.join(word.split())
- length = len(word)
- root = math.sqrt(length)
- floor = math.floor(root)
- ceil = math.ceil(root)
- if floor * ceil < length :
- floor = ceil
- result = ""
- for j in range(ceil):
- #print(f"j:{j}")
- for i in range(floor):
- #print(f"i:{i}")
- if (i*ceil + j) >= length:
- continue
- else:
- #print(word[i*ceil + j], end = "")
- result = result + word[i*ceil + j]
- #print(" ", end = "")
- if j != ceil:
- result = result + " "
- #print()
- return result
- if __name__ == '__main__':
- fptr = open(os.environ['OUTPUT_PATH'], 'w')
- s = input()
- result = encryption(s)
- fptr.write(result + '\n')
- fptr.close()
Add Comment
Please, Sign In to add comment