first commit

This commit is contained in:
Stephan 2021-10-26 23:07:58 +02:00
commit 26aa8714da
3 changed files with 47 additions and 0 deletions

7
0/0.py Normal file
View File

@ -0,0 +1,7 @@
from typing import Mapping
solution = 2 ** 38
if __name__ == '__main__':
print(solution)

40
1/cesar_shift.py Normal file
View File

@ -0,0 +1,40 @@
import string
URL = 'http://www.pythonchallenge.com/pc/def/map.html'
SECRET = ("g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq "
"ypc dmp. bmgle gr gl zw fylb gq glcddgagclr ylb rfyr'q ufw "
"rfgq rcvr gq qm jmle. sqgle qrpgle.kyicrpylq() gq "
"pcamkkclbcb. lmu ynnjw ml rfc spj.")
ASCII_ALPHABET = string.ascii_lowercase
def shift_chars(riddle_string, shift_by_int):
# Shift only between ord 96 and 121
shifted_string = ''
for char in riddle_string:
char_value = ord(char)
if char_value >= ord(ASCII_ALPHABET[-1]) - 1:
shifted_string += chr(ord(char) -
len(ASCII_ALPHABET) + shift_by_int)
elif char_value <= ord(ASCII_ALPHABET[0]) - 1:
shifted_string += char
else:
shifted_string += chr((ord(char)) + shift_by_int)
return shifted_string
def main():
shifted_secret = shift_chars(SECRET, 2)
print('Shifted secret:', shifted_secret)
shifted_url = shift_chars(URL, 2)
print('Shifted url:', shifted_url)
new_url = URL.replace('map', shifted_url.split('/')[-1][:3])
print('New url:', new_url)
if __name__ == '__main__':
main()

0
README.md Normal file
View File