Skip to content

davidscholberg/project_euler

Repository files navigation

Project Euler

These are my solutions to the Project Euler problem set. The solutions are written in a mixture of Python and Cython.

Development Setup

  • Install required packages. The exact command will vary per Linux distribution. The command given below is for Fedora.
    • python3-devel, gcc, and gcc-c++ are required to compile the Cython modules in this project.
    • python-unversioned-command is optional, but it allows you to use the python command without having to type python3.
sudo dnf install python3 python3-devel python-unversioned-command gcc gcc-c++
  • Get project source.
git clone https://github.com/davidscholberg/project_euler.git
cd project_euler
python -m venv .venv
source .venv/bin/activate
  • Build and install the project package as an editable install.
    • Note that this command will need to be run after every change to a cython file (.pyx) in order for the change to take effect. This does not apply to changes to python files.
pip install --editable .
  • Install commit hook to run the unit tests on commit.
./install_commit_hooks

Running Solutions

To run the solution for a particular problem, pass the problem number to the solve script:

solve 24

The solve script runs the solution and compares the computed answer against the correct answer, the list of which was obtained from luckytoilet/projecteuler-solutions.

Note that the solve script is automatically generated by setuptools as an entry point.

Project Directory Structure

  • project_euler/ - Main project package. All python/cython source files go in here.
    • data/ - Input data for problems that have non-trivial input.
    • solutions/ - Solution files, one per solution. Logic should be kept to a minimum here.
    • util/ - Package where reusable logic resides. All code here should have unit tests.
  • install_commit_hooks - Script to install unit test commit hook.
  • test - Script that runs all unit tests.

About

My solutions to the Project Euler problem set, written in a mixture of Python and Cython.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published