Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 038e0d9

Browse files
author
Deepanshu Mishra
committed
added an Encryption program
1 parent ec63f1c commit 038e0d9

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

‎HackerRank-Encryption/Encryption.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/python3
2+
3+
import math
4+
import os
5+
6+
# complete the encryption function below.
7+
def encryption(s):
8+
L = len(s)
9+
rows = int(math.floor(L**(0.5)))
10+
columns = int(math.ceil(L**(0.5)))
11+
output = ""
12+
for i in range(columns):
13+
k = i
14+
for j in range(k,L,columns):
15+
output+=s[j]
16+
output+=" "
17+
return output
18+
19+
20+
if __name__ == '__main__':
21+
fptr = open(os.environ['OUTPUT_PATH'], 'w')
22+
s = input()
23+
result = encryption(s)
24+
fptr.write(result + '\n')
25+
fptr.close()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /