Skip to main content

Helper architecture for tackling Project Euler problems

Project description

PyPI Travis AppVeyor Codecov

Pyler is a lib that helps tackling Project Euler problems using Python

How ?

$ pip install pyler

Generate a file

# generates the file for problem 1
$ pyler gen 1
# generates the file for problems 1 to 10, 14 and 17 to 24
$ pyler gen 1-10,14,17-24
# generates the first not-yet-generated problem
$ pyler gen next
# generates all available problems
$ pyler gen all

You get the idea !

This will generate a file that has more or less everything for beginning the real work. Just fill the variables and code your solution into solver.

from pyler import EulerProblem


class Problem0001(EulerProblem):
    """
    If we list all the natural numbers below 10 that are multiples of 3 or 5, we
    get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the
    multiples of 3 or 5 below 1000.
    """
    problem_id = 1
    simple_input = 0
    simple_output = 1
    real_input = 0

    def solver(self, input_val):
        return 0

if __name__ == '__main__':
    import unittest
    unittest.main()

You can change the path where the files are being generated using --path and the template used with --template=path/to/template.py, the template file must be compatible with Python’s [.format](https://pyformat.info/) function and will recieve 2 variables : doc and problem_id

BTW : yes, the docstring is scraped from the website.

Test your solution

# Tests the implementation of the first problem
$ pyler test 1
# Well I'm sure you know what this does
$ pyler test 1-10,14,17-24
# Tests the last problem
$ pyler test last

You may also use unittest or the testing tool of your choice that accept unittest TestCases. Calling Python on the problem file directly will also launch the tests.

Launching the tests on your solution module will test your solution for :

  • The simple test case (the one that’s given in the statement)

  • The real test case (it will check on the real website to do so). The first time, it will ask for your credentials (stored in a local file .pyler.conf) and now and then, it will ask you to solve the captchas. If you have already validated the problem, it will check the solution from the page. Otherwise, it will submit the solution for you.

  • A test ensuring that your implementation takes less than 1 minute. If you’re not using Windows, it will stop at 1 minute. Otherwise, it will fail when the computation is over.

You can use any number of --only=x and --skip=x flags with x being simple, real, time.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyler-0.2.0.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

pyler-0.2.0-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file pyler-0.2.0.tar.gz.

File metadata

  • Download URL: pyler-0.2.0.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pyler-0.2.0.tar.gz
Algorithm Hash digest
SHA256 f4c5a99ef2b5ca3db4371c8107f66ba9985d0089fb94b17f652ca87b5a26f24d
MD5 f520ecdccd75cd07b64c96f5e6cb7f11
BLAKE2b-256 74d55b85750f13e45aea2881fb839e09d449c80c5115358410b7239b9578e5cd

See more details on using hashes here.

File details

Details for the file pyler-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pyler-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3b2e2eb2c1ae0b9d16c6c2fda9b166f63514ac0be2696e355e473f951bda3463
MD5 95f65e60526d340b9d989e2598287e4c
BLAKE2b-256 f84b56b17bea4c62784bd96c3fa87301d1d0eddac0ba7eb34a5cdcbe71d1fbd7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page