rail-fence

This commit is contained in:
Maxime Vorwerk
2024-07-07 13:59:45 +02:00
parent c386f178e2
commit 5fe90b5325
2 changed files with 48 additions and 0 deletions

47
rail_fence/sol.py Executable file
View File

@@ -0,0 +1,47 @@
#!/home/maxime/.pyvenv/bin/python3
with open("message.txt", 'r') as f:
text = f.read()
dec = [" "] * len(text)
i = 0
j = 0
while True:
dec[j] = text[i]
i += 1
j += 6
if j >= len(text):
break
j = 1
while True:
dec[j] = text[i]
i += 1
j += 4
if j >= len(text):
break
dec[j] = text[i]
i += 1
j += 2
if j >= len(text):
break
j = 2
while True:
dec[j] = text[i]
i += 1
j += 2
if j >= len(text):
break
dec[j] = text[i]
i += 1
j += 4
if j >= len(text):
break
j = 3
while True:
dec[j] = text[i]
i += 1
j += 6
if j >= len(text):
break
print(''.join(dec))