Skip to content

Added solution for Project Euler problem 59 #4031

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Dec 13, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Added doctests for Project Euler problem 59
  • Loading branch information
fpringle committed Dec 13, 2020
commit 32a2d4afe66fdc80ae6e6c0d648b90952df69099
8 changes: 4 additions & 4 deletions project_euler/problem_059/sol1.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,19 @@ def filter_common_word(possibles: List[str], common_word: str) -> List[str]:
return [possible for possible in possibles if common_word in possible.lower()]


def solution() -> int:
def solution(filename: str = "p059_cipher.txt") -> int:
"""
Test the ciphertext against all possible 3-character keys, then narrow down the
possibilities by filtering using common words until there's only one possible
decoded message.
>>> solution("test_cipher.txt")
3000
"""
ciphertext: List[int]
possibles: List[str]
common_word: str
decoded_text: str
data: str = (
Path(__file__).parent.joinpath("p059_cipher.txt").read_text(encoding="utf-8")
)
data: str = Path(__file__).parent.joinpath(filename).read_text(encoding="utf-8")

ciphertext = [int(number) for number in data.strip().split(",")]

Expand Down
1 change: 1 addition & 0 deletions project_euler/problem_059/test_cipher.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
63,13,28,75,0,23,14,8,0,76,22,89,12,4,13,14,69,16,24,69,29,4,18,23,69,69,59,14,69,11,14,4,29,18