Skip to content

Commit

Permalink
Merge pull request #29 from vil02/simplify_imports_in_create_puzzle
Browse files Browse the repository at this point in the history
refactor: add `in_decrypt_str` argument to `_run_puzzle`
vil02 authored Jul 24, 2024
2 parents 7411aba + 2408ba8 commit b48f01d
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions puzzle_generator/create_puzzle.py
Original file line number Diff line number Diff line change
@@ -4,22 +4,21 @@

from .puzzle_data_encryption import decrypt_data, encrypt_data
from . import simple_encryption_utils as seu
from .simple_encryption_utils import decrypt_str
from . import bytestr_utils as bu


def _run_puzzle(in_puzzle):
def _run_puzzle(in_puzzle, in_decrypt_str):
print(in_puzzle["str"])
if "rest" in in_puzzle:
this_pass = input()
new_puzzle = decrypt_data(
in_puzzle["rest"], in_puzzle["hash"], this_pass, decrypt_str
in_puzzle["rest"], in_puzzle["hash"], this_pass, in_decrypt_str
)
if new_puzzle is None:
print("This is a wrong answer. Try again!")
sys.exit(1)
else:
_run_puzzle(new_puzzle)
_run_puzzle(new_puzzle, in_decrypt_str)


def _create_str(in_modules, in_functions, in_encrypted_puzzle):
@@ -31,7 +30,7 @@ def _create_str(in_modules, in_functions, in_encrypted_puzzle):
modules_str = "\n".join("import " + _ for _ in in_modules) + "\n"
functions_str = "\n".join(inspect.getsource(_) for _ in in_functions)
puzzle_data_str = f"_PUZZLE = {in_encrypted_puzzle}"
call_str = "_run_puzzle(_PUZZLE)"
call_str = "_run_puzzle(_PUZZLE, decrypt_str)"

return (
"\n".join(
@@ -52,7 +51,7 @@ def create(in_puzzle, output_path: pathlib.Path) -> None:
seu.proc_bytes,
seu.decrypt_bytes,
bu.bytestr_to_bytes,
decrypt_str,
seu.decrypt_str,
decrypt_data,
_run_puzzle,
]

0 comments on commit b48f01d

Please sign in to comment.