Compare commits

..

No commits in common. "3c7bf475bb74bcd95315ea04bd8756d551f6791d" and "b7642ffd36232473a0c1c6ea12f10a0eef2d5b07" have entirely different histories.

10 changed files with 13 additions and 2606 deletions

4
0/0.py Normal file
View File

@ -0,0 +1,4 @@
solution = 2 ** 38
if __name__ == '__main__':
print(solution)

11
00/0.py
View File

@ -1,11 +0,0 @@
from utils.Url import Url
def main():
solution = 2 ** 38
builder = Url()
builder.solution = solution
print(builder.url)
if __name__ == '__main__':
main()

View File

@ -1,29 +0,0 @@
from collections import Counter
from utils.Url import Url
def count_string():
with open('string.txt') as file:
string = file.read()
return Counter(string)
def get_lowest(counted_dict):
lowest_string = ''
for key in counted_dict:
if counted_dict[key] == 1:
lowest_string += key
return lowest_string
def main():
counted = count_string()
lowest_string = get_lowest(counted)
builder = Url()
builder.solution = lowest_string
print(builder.url)
if __name__ == '__main__':
main()

File diff suppressed because it is too large Load Diff

View File

@ -1,23 +0,0 @@
from utils.Url import Url
from utils.read import read_string
import re
def find_pattern(pattern_string):
string = read_string('string.txt')
regex = re.compile(pattern_string)
matches = regex.findall(string)
return ''.join(matches)
def main():
pattern_string = r'[a-z][A-Z]{3}(?P<solution>[a-z]){01}[A-Z]{3}[a-z]'
string = find_pattern(pattern_string)
builder = Url()
builder.slug = 'php'
builder.solution = string
print(builder.url)
if __name__ == '__main__':
main()

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,6 @@
import string import string
from utils.Url import Url
URL = 'http://www.pythonchallenge.com/pc/def/map.html'
SECRET = ("g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq " 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 " "ypc dmp. bmgle gr gl zw fylb gq glcddgagclr ylb rfyr'q ufw "
@ -26,11 +27,13 @@ def shift_chars(riddle_string, shift_by_int):
def main(): def main():
shifted_secret = shift_chars(SECRET, 2) shifted_secret = shift_chars(SECRET, 2)
print(shifted_secret) print('Shifted secret:', shifted_secret)
shifted_url = shift_chars('map', 2) shifted_url = shift_chars(URL, 2)
builder = Url() print('Shifted url:', shifted_url)
builder.solution = shifted_url new_url = URL.replace('map', shifted_url.split('/')[-1][:3])
print(builder.url) print('New url:', new_url)
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -1,53 +0,0 @@
class Url:
"""
Class to build the python challenge url with the solution string and an
optional slug.
"""
def __init__(self):
self._url = ''
self._slug = 'html'
self._solution = ''
BASE_URL = 'http://www.pythonchallenge.com/pc/def'
@property
def url(self):
"""
Gets the url string of the builder.
:return: url string
"""
return f'{self.BASE_URL}/{self.solution}.{self.slug}'
@property
def solution(self):
"""
Returns the solution string
:return: solution string
"""
return self._solution
@solution.setter
def solution(self, solution):
"""
Sets the solution string
:param solution: str
"""
self._solution = solution
@property
def slug(self):
"""
Returns the slug string
:return: slug string
"""
return self._slug
@slug.setter
def slug(self, slug):
"""
Sets the slug string
:param slug: str
:return: slug string
"""
self._slug = slug

View File

View File

@ -1,14 +0,0 @@
"""
Sone utility functions that can be reused for the python challenge.
"""
def read_string(path):
"""
Read a string from a file provided by a path string.
:param path: A path string
:return: file content as a string
"""
with open(path) as file:
string = file.read()
return string