This repository contains two things:
- Solutions to some Project Euler problems.
- A CLI tool for managing these solutions and the library code shared between problems.
The latter is probably of more interest, because there's many many solutions to the first few Project Euler problems floating around the internet.
If you want to use this for your own solutions, you can clone this repo and wipe my solution state:
- Clone the repository however you prefer
- Install requirements:
pip install -r requirements.txt
- Delete existing code:
rm lib/* problems/* resources/*
- Clear answer file:
rm answers.bin; touch answers.bin
This repository has type annotations; either mypy or Pyre should work. Personally I use the latter.
To use this tool, run main.py
with one of the following commands. (
Most of these commands also take arguments of the form a-b
, indicating problems a to b, inclusive, and the special value all
, which has slightly different meanings for different commands.
Lastly, you can always pass --help
for more details on a particular command.
create <n>
: Create a new fileproblems/<n>.py
for problem #n.- It fetches the problem description from the website and (poorly) formats it as a doc comment.
run <n>
: Run the code inproblems/<n>.py
, which should solve problem #n.- The answer is printed to the user, and compared against the saved answer (if any).
- User is prompted to save the answer.
check <n>
: Runs the code inproblems/<n>.py
and compares it to the saved answer.- If run without
n
, checks all problems.
- If run without
time <n>
: Runs the problem code several times and reports the average time taken.overview
: Shows an overview of which problems have been completed or not.answers
: Contains subcommands for manipulating the answer save file.show <n>
: Shows the saved entries from the answer file.delete <n>
: Deletes the specific entry from the answer file.