Skip to content

Commit

Permalink
Rename Project Euler directories and other dependent changes (TheAlgo…
Browse files Browse the repository at this point in the history
…rithms#3300)

* Rename all Project Euler directories:

Reason:
The change was done to maintain consistency throughout the directory
and to keep all directories in sorted order.

Due to the above change, some config files had to be modified:
'problem_22` -> `problem_022`

* Update scripts to pad zeroes in PE directories
  • Loading branch information
dhruvmanila authored Oct 15, 2020
1 parent 2d7e08e commit 44254cf
Show file tree
Hide file tree
Showing 177 changed files with 108 additions and 112 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- uses: actions/setup-python@v2
- run: pip install codespell
- run: |
SKIP="./.*,./other/dictionary.txt,./other/words,./project_euler/problem_22/p022_names.txt"
SKIP="./.*,./other/dictionary.txt,./other/words,./project_euler/problem_022/p022_names.txt"
codespell --ignore-words-list=ans,fo,followings,hist,iff,secant,som,tim --skip=$SKIP --quiet-level=2
- name: Codespell comment
if: ${{ failure() }}
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ repos:
- id: codespell
args:
- --ignore-words-list=ans,fo,followings,hist,iff,secant,som,tim
- --skip="./.*,./other/dictionary.txt,./other/words,./project_euler/problem_22/p022_names.txt"
- --skip="./.*,./other/dictionary.txt,./other/words,./project_euler/problem_022/p022_names.txt"
- --quiet-level=2
exclude: |
(?x)^(
other/dictionary.txt |
other/words |
project_euler/problem_22/p022_names.txt
project_euler/problem_022/p022_names.txt
)$
- repo: local
hooks:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
200 changes: 100 additions & 100 deletions project_euler/project_euler_answers.json
Original file line number Diff line number Diff line change
@@ -1,103 +1,103 @@
{
"01": "233168",
"02": "4613732",
"03": "6857",
"04": "906609",
"05": "232792560",
"06": "25164150",
"07": "104743",
"08": "23514624000",
"09": "31875000",
"10": "142913828922",
"11": "70600674",
"12": "76576500",
"13": "5537376230",
"14": "837799",
"15": "137846528820",
"16": "1366",
"17": "21124",
"18": "1074",
"19": "171",
"20": "648",
"21": "31626",
"22": "871198282",
"23": "4179871",
"24": "2783915460",
"25": "4782",
"26": "983",
"27": "-59231",
"28": "669171001",
"29": "9183",
"30": "443839",
"31": "73682",
"32": "45228",
"33": "100",
"34": "40730",
"35": "55",
"36": "872187",
"37": "748317",
"38": "932718654",
"39": "840",
"40": "210",
"41": "7652413",
"42": "162",
"43": "16695334890",
"44": "5482660",
"45": "1533776805",
"46": "5777",
"47": "134043",
"48": "9110846700",
"49": "296962999629",
"50": "997651",
"51": "121313",
"52": "142857",
"53": "4075",
"54": "376",
"55": "249",
"56": "972",
"57": "153",
"58": "26241",
"59": "129448",
"60": "26033",
"61": "28684",
"62": "127035954683",
"63": "49",
"64": "1322",
"65": "272",
"66": "661",
"67": "7273",
"68": "6531031914842725",
"69": "510510",
"70": "8319823",
"71": "428570",
"72": "303963552391",
"73": "7295372",
"74": "402",
"75": "161667",
"76": "190569291",
"77": "71",
"78": "55374",
"79": "73162890",
"80": "40886",
"81": "427337",
"82": "260324",
"83": "425185",
"84": "101524",
"85": "2772",
"86": "1818",
"87": "1097343",
"88": "7587457",
"89": "743",
"90": "1217",
"91": "14234",
"92": "8581146",
"93": "1258",
"94": "518408346",
"95": "14316",
"96": "24702",
"97": "8739992577",
"98": "18769",
"99": "709",
"001": "233168",
"002": "4613732",
"003": "6857",
"004": "906609",
"005": "232792560",
"006": "25164150",
"007": "104743",
"008": "23514624000",
"009": "31875000",
"010": "142913828922",
"011": "70600674",
"012": "76576500",
"013": "5537376230",
"014": "837799",
"015": "137846528820",
"016": "1366",
"017": "21124",
"018": "1074",
"019": "171",
"020": "648",
"021": "31626",
"022": "871198282",
"023": "4179871",
"024": "2783915460",
"025": "4782",
"026": "983",
"027": "-59231",
"028": "669171001",
"029": "9183",
"030": "443839",
"031": "73682",
"032": "45228",
"033": "100",
"034": "40730",
"035": "55",
"036": "872187",
"037": "748317",
"038": "932718654",
"039": "840",
"040": "210",
"041": "7652413",
"042": "162",
"043": "16695334890",
"044": "5482660",
"045": "1533776805",
"046": "5777",
"047": "134043",
"048": "9110846700",
"049": "296962999629",
"050": "997651",
"051": "121313",
"052": "142857",
"053": "4075",
"054": "376",
"055": "249",
"056": "972",
"057": "153",
"058": "26241",
"059": "129448",
"060": "26033",
"061": "28684",
"062": "127035954683",
"063": "49",
"064": "1322",
"065": "272",
"066": "661",
"067": "7273",
"068": "6531031914842725",
"069": "510510",
"070": "8319823",
"071": "428570",
"072": "303963552391",
"073": "7295372",
"074": "402",
"075": "161667",
"076": "190569291",
"077": "71",
"078": "55374",
"079": "73162890",
"080": "40886",
"081": "427337",
"082": "260324",
"083": "425185",
"084": "101524",
"085": "2772",
"086": "1818",
"087": "1097343",
"088": "7587457",
"089": "743",
"090": "1217",
"091": "14234",
"092": "8581146",
"093": "1258",
"094": "518408346",
"095": "14316",
"096": "24702",
"097": "8739992577",
"098": "18769",
"099": "709",
"100": "756872327473",
"101": "37076114526",
"102": "228",
Expand Down Expand Up @@ -724,4 +724,4 @@
"723": "1395793419248",
"724": "18128250110",
"725": "4598797036650685"
}
}
14 changes: 5 additions & 9 deletions project_euler/validate_solutions.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,15 @@ def collect_solution_file_paths() -> List[pathlib.Path]:
return solution_file_paths


def expand_parameters(param: pathlib.Path) -> str:
"""Expand parameters in pytest parametrize"""
project_dirname = param.parent.name
solution_filename = param.name
return f"{project_dirname}/{solution_filename}"


@pytest.mark.parametrize(
"solution_path", collect_solution_file_paths(), ids=expand_parameters
"solution_path",
collect_solution_file_paths(),
ids=lambda path: f"{path.parent.name}/{path.name}",
)
def test_project_euler(solution_path: pathlib.Path):
"""Testing for all Project Euler solutions"""
problem_number: str = solution_path.parent.name[8:] # problem_[extract his part]
# problem_[extract this part] and pad it with zeroes for width 3
problem_number: str = solution_path.parent.name[8:].zfill(3)
expected: str = PROBLEM_ANSWERS[problem_number]
solution_module = convert_path_to_module(solution_path)
answer = str(solution_module.solution())
Expand Down

0 comments on commit 44254cf

Please sign in to comment.