From 6f03d9057b2696b41ebe4a9a23df026f3e150b47 Mon Sep 17 00:00:00 2001 From: kj1800 <72385282+kj1800@users.noreply.github.com> Date: Mon, 5 Oct 2020 03:27:17 -0700 Subject: [PATCH] Create encryption.py --- encryption.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 encryption.py diff --git a/encryption.py b/encryption.py new file mode 100644 index 0000000..ea83518 --- /dev/null +++ b/encryption.py @@ -0,0 +1,27 @@ +@@ -0,0 +1,25 @@ +#!/bin/python3 + +import math +import os + +# complete the encryption function below. +def encryption(s): + L = len(s) + rows = int(math.floor(L**(0.5))) + columns = int(math.ceil(L**(0.5))) + output = "" + for i in range(columns): + k = i + for j in range(k,L,columns): + output+=s[j] + output+=" " + return output + + +if __name__ == '__main__': + fptr = open(os.environ['OUTPUT_PATH'], 'w') + s = input() + result = encryption(s) + fptr.write(result + '\n') + fptr.close() +