Coder Social home page Coder Social logo

sir-gon / algorithm-exercises-py Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 3.0 899 KB

Project Euler algorithms exercises solved in Python 3, running with built-in unittest suit. Developed with TDD.

License: MIT License

Dockerfile 0.89% Makefile 2.23% Python 96.88%
algorithms algorithms-and-data-structures exercises python tdd

algorithm-exercises-py's Introduction

Algorithm Exercises (Python 3)

Python CI codecov FOSSA Status CII Best Practices Markdown Lint

GitHub GitHub language count GitHub top language

Quality Gate Status Coverage Bugs Code Smells Duplicated Lines (%)

What is this?

Project Euler provide some algorithms and mathematical problems to solve to be used as experience tests.

Use this answers to learn some tip and tricks for algorithms tests.

Why I publish solutions?

As Project Euler says:

https://algorithm-exercises.net/about#publish

I learned so much solving problem XXX, so is it okay to publish my solution elsewhere?
It appears that you have answered your own question. There is nothing quite like that "Aha!" moment when you finally beat a problem which you have been working on for some time. It is often through the best of intentions in wishing to share our insights so that others can enjoy that moment too. Sadly, that will rarely be the case for your readers. Real learning is an active process and seeing how it is done is a long way from experiencing that epiphany of discovery. Please do not deny others what you have so richly valued yourself.

However, the rule about sharing solutions outside of Project Euler does not apply to the first one-hundred problems, as long as any discussion clearly aims to instruct methods, not just provide answers, and does not directly threaten to undermine the enjoyment of solving later problems. Problems 1 to 100 provide a wealth of helpful introductory teaching material and if you are able to respect our requirements, then we give permission for those problems and their solutions to be discussed elsewhere.

If you have better answers or optimal solutions, fork and PR-me

Enjoy ๐Ÿ˜ !

Using Python 3 native runtime

Requirements

You must install dependencies:

pip3 install -r requirements.txt

Or using make

make dependencies

Minimal dependencies

Third party libraries for CI/CD pipeline and TDD cycle (not used in runtime):

pip3 install coverage pylint pytest

Testing silently

Every problem is a function with unit test. Unit test has test cases and input data to solve the problem.

Run all tests:

pytest --verbose -o log_cli=true --log-cli-level=INFO --full-trace src/

Testing with full logs

Run all tests with debug outputs:

pytest --verbose -o log_cli=true --log-cli-level=DEBUG --full-trace src/

Testing using make

make test

Enable all large BRUTEFORCE tests

Direct in host using a make:

make test -e BRUTEFORCE=true

Enable all DEBUG outputs

make test -e LOG_LEVEL=debug

Enable all large BRUTEFORCE tests and all DEBUG outputs

make test -e LOG_LEVEL=debug -e BRUTEFORCE=true

Running with Docker ๐Ÿณ

Build a complete image with and run all tests

Running container with testing (final) target.

Designed to store all application files and dependencies as a complete runnable image. Coverage results will be stored in host /coverage directory (mounted as volume).

# Build a complete image
docker-compose build algorithm-exercises-py
docker-compose run --rm algorithm-exercises-py make test coverage

Enable BRUTEFORCE tests with full DEBUG output

With docker-compose:

docker-compose --profile testing run --rm algorithm-exercises-py make test -e LOG_LEVEL=debug -e BRUTEFORCE=true

Using make:

make docker/compose-run -e LOG_LEVEL=DEBUG -e BRUTEFORCE=true

Build and run a development image

Running container with development target. Designed to develop on top of this image. All source application is mounted as a volume in /app directory. Dependencies should be installed to run (not present in this target) so, you must install dependencies before run (or after a dependency add/change).

# install dependencies using docker runtime and store them in host directory
docker-compose build algorithm-exercises-py-dev
docker-compose run --rm algorithm-exercises-py-dev make dependencies
docker-compose run --rm algorithm-exercises-py-dev make test

About development

Developed with runtime:

python3 --version
Python 3.12.1

License

FOSSA Status

Coverage

Coverage

algorithm-exercises-py's People

Contributors

sir-gon avatar renovate[bot] avatar dependabot[bot] avatar snyk-bot avatar lgtm-migrator avatar

Stargazers

 avatar Martin Ndirangu avatar

Watchers

 avatar  avatar

algorithm-exercises-py's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

docker-compose
compose.yaml
dockerfile
Dockerfile
  • python 3.12.3-alpine3.20
  • node 20.14.0-alpine3.20
github-actions
.github/workflows/codeql.yml
  • actions/checkout v4@a5ac7e51b41094c92402da3b24376905380afc29
  • github/codeql-action v3
  • github/codeql-action v3
  • github/codeql-action v3
.github/workflows/docker-image.yml
  • actions/checkout v4@a5ac7e51b41094c92402da3b24376905380afc29
.github/workflows/gitleaks.yml
  • actions/checkout v4
  • gitleaks/gitleaks-action v2
.github/workflows/markdown-lint.yml
  • actions/checkout v4@a5ac7e51b41094c92402da3b24376905380afc29
  • actions/setup-node v4
.github/workflows/python-coverage.yml
  • actions/checkout v4@a5ac7e51b41094c92402da3b24376905380afc29
  • codecov/codecov-action v4
.github/workflows/python.yml
  • actions/checkout v4@a5ac7e51b41094c92402da3b24376905380afc29
pip_requirements
requirements.txt
  • astroid ==3.2.2
  • attrs ==23.2.0
  • autopep8 ==2.2.0
  • coverage ==7.5.3
  • dill ==0.3.8
  • exceptiongroup ==1.2.1
  • flake8 ==7.0.0
  • iniconfig ==2.0.0
  • isort ==5.13.2
  • lazy-object-proxy ==1.10.0
  • mccabe ==0.7.0
  • nodeenv ==1.9.1
  • packaging ==24.0
  • platformdirs ==4.2.2
  • pluggy ==1.5.0
  • pycodestyle ==2.11.1
  • pyflakes ==3.2.0
  • pylint ==3.2.3
  • pyright ==1.1.366
  • pytest ==8.2.2
  • pytest-cov ==5.0.0
  • tomli ==2.0.1
  • tomlkit ==0.12.5
  • typing_extensions ==4.12.2
  • wrapt ==1.16.0
  • setuptools >=65.5.1

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.