Commit Graph

179 Commits

Author SHA1 Message Date
Nelson Stoik
1c0deb88ac
Coding style change for project_euler problem 36 and 35 (#3062)
* add problem url. Add typehint, default value and doctest

* run black

* add project url. add solution function for problem 35

* add space between imports on problem 35

* Update sol1.py

* Update sol1.py

Co-authored-by: Dhruv <dhruvmanila@gmail.com>
2020-10-09 08:35:13 +05:30
Suyash Gupta
a3bbcd5f88
[Project Euler] Added type hints and refactored the code for Problem 14 (#3047)
* added type hints and refactored the code a bit

* made output statement more explicit

* used f-strings and updated type hints

* modified solution function to return an integer solution

* updated docstring

* Update sol1.py

* Update sol2.py

Co-authored-by: Dhruv <dhruvmanila@gmail.com>
2020-10-09 08:33:23 +05:30
fa1l
261be28120
Fix coding style for Project Euler problem 39 (#3023)
* improvements for project euler task 39

* add tests for solution()

* fixed a typo

* Update sol1.py

Co-authored-by: Dhruv <dhruvmanila@gmail.com>
2020-10-09 08:13:54 +05:30
Aman Saxena
c9500dc89f
[Project Euler] Fix code style for problem 56 (#3050)
* rename method for project_euler/problem #56

* Update sol1.py

* Removed whitespaces

Co-authored-by: Dhruv <dhruvmanila@gmail.com>
2020-10-08 19:07:09 +05:30
kalpanajangra
7d0d77334f
Add Project Euler Problem 71: Fixes #2695 (#2785) 2020-10-08 19:55:23 +08:00
Nelson Stoik
e24248524a
Coding style with default argument for project_euler problem 27 (#3020)
* add default arguments and problem url

* Update and rename problem_27_sol1.py to sol1.py

Co-authored-by: Dhruv <dhruvmanila@gmail.com>
2020-10-08 16:53:00 +05:30
Edward Nuno
899870be4c
Add style improvements to Project Euler problem 9 (#3046) 2020-10-08 16:51:32 +05:30
Joan
7d54056497
[Project Euler] Fix code style in Problem 41 (#2992)
* add problem title and link, fix f-string

Signed-off-by: joan.rosellr <joan.rosellr@gmail.com>

* fix code style and improve doctests

Signed-off-by: joan.rosellr <joan.rosellr@gmail.com>

* undo changes to the main call

Signed-off-by: joan.rosellr <joan.rosellr@gmail.com>

* remove assignment operator in f-string

Signed-off-by: joan.rosellr <joan.rosellr@gmail.com>

* add newline after first import to attempt to fix pre-commit workflow

Signed-off-by: joan.rosellr <joan.rosellr@gmail.com>

* undo doctest changes, rename compute_pandigital_primes to solution

Signed-off-by: joan.rosellr <joan.rosellr@gmail.com>

* update solution to return the actual solution instead of a list

Signed-off-by: joan.rosellr <joan.rosellr@gmail.com>

* Update sol1.py

Co-authored-by: Dhruv <dhruvmanila@gmail.com>
2020-10-08 13:57:07 +05:30
Dhruv
719c5562d9
Add default args and type hints for problem 7 (#2973)
- Add default argument values
- Add type hints
- Change one letter variable names to a more descriptive one
- Add doctest for `solution()`
2020-10-08 07:57:47 +02:00
Wen Hong
6541236fdf
Add solution method for project_euler/problem_37 (#2998)
* add solution method

* fix formatting
2020-10-08 09:27:14 +05:30
Edward Nuno
f3fe29cea1
Add style improvements to Project Euler problem 8 (#3001) 2020-10-08 09:21:17 +05:30
Nelson Stoik
ef53bbdf5a
Style Improvements for project_euler/problem_26 (#2958)
* add typehints and docstrings

* add typehint and default value

* add typehint and default value. Removed unused variable.

* do not modifiy the given solution

* add doctests

* update sol1 after running black

* add typehint, docstring, and doctest

* update sol2 after running black

* add full problem statement and solution function with typehint and doctest

* renamed original function instead of adding new one

* don't alter original solution
2020-10-08 08:52:24 +05:30
Suyash Gupta
6a5a022082
Add type hints and default args for Project Euler problem 5 (#2982)
* add type hints and default args for problem 5

* Update sol1.py

* Update sol2.py

Co-authored-by: Dhruv <dhruvmanila@gmail.com>
2020-10-08 08:50:11 +05:30
Wen Hong
ff9be86390
Hacktoberfest 2020: Rename method for project_euler/problem_99 (#2981)
* name method solution in project_euler/problem99

* rename function
2020-10-07 20:46:11 +05:30
Joan
a698fa9a3f
[Project Euler] Fix code style in Problem 55 (#2985)
* fix code style and update problem description with link

Signed-off-by: joan.rosellr <joan.rosellr@gmail.com>

* Update sol1.py

Co-authored-by: Dhruv <dhruvmanila@gmail.com>
2020-10-07 20:39:36 +05:30
Joan
c14cfa32df
Address #2786 - Fix code style in Project Euler Problem 76 (#2978)
* fix code style in problem 76

Signed-off-by: joan.rosellr <joan.rosellr@gmail.com>

* Update sol1.py

* Update sol1.py

* Remove trailing whitespace

Co-authored-by: Dhruv <dhruvmanila@gmail.com>
2020-10-07 19:08:02 +05:30
JasirZaeem
05616ca38e
Update code style for Project Euler Problem 28 (#2976)
Add default arguments, typehints and rename solution function for Porject Euler Problem 28
2020-10-07 18:35:06 +05:30
Dhruv
11a5afd8a1
Add type hints and default args for problem 20 (#2962)
- Improved variable names
- Added type hints
- Added default argument values for validate_solutions script
2020-10-07 17:59:55 +08:00
Edward Nuno
a5000d32ed
Add style improvements to solutions for Project Euler Problem 04 (#2945)
* Fix typehints in project_euler/problem01

Squashed commit of the following:

commit 6801d073b31bf702814861cd3b07b634ca295bfa
Author: Archaengel <god11341258@gmail.com>
Date:   Mon Oct 5 16:40:10 2020 -0700

    Fix typehints in project_euler/problem01

commit 29afc3af114abd1b99dc3f7c8fc99128229db131
Author: Archaengel <god11341258@gmail.com>
Date:   Mon Oct 5 15:06:34 2020 -0700

    Add typehints and default argument for project_euler/problem_01

* Add default args, typehints, and expand variable names for PE prob 02

* Add style improvements for first solution of PE Problem 02

* Add default arg and typehints for second solution of PE Problem 02

* Add default arg for third solution of PE Problem 02

* Add style improvements for 1st soln of PE problem 03

* Add default arg and typehints for 2nd soln of PE problem 03

* Add default arg for 3rd soln of PE problem 03

* Remove unnecessary newlines

* Remove unnecessary newlines

* Fix end of file for 2nd soln in PE problem 03

* Add style improvements to solutions for PE problem 04

* Restore original newlines in soln for PE problem 04

* Fix punctuation in docstring for PE problem 04

* Restore solution bodies for PE problem 04

* Expand variable names for 2nd soln of PE problem 04
2020-10-07 10:33:34 +05:30
Dhruv
ddf83ec886
Add default arguments for Project Euler problem 6 (#2957)
- Add default arguments to solution function
- Add link to Project Euler problem 6
- Add doctest for testing `solution()`
- Removed test_solutions.py as it is redundant
2020-10-07 10:17:43 +05:30
Nelson Stoik
4d4ce400ec
Add typehints and default input for project_euler/problem_25 (#2901)
* add typehints and docstrings

* add typehint and default value

* add typehint and default value. Removed unused variable.

* do not modifiy the given solution

* add doctests

* update sol1 after running black

* add typehint, docstring, and doctest

* update sol2 after running black
2020-10-07 09:27:25 +05:30
Noah H
91ad30c2b0
Bring problem_29 solution in line with project style guidelines (#2949) 2020-10-07 08:33:03 +05:30
Edward Nuno
54401387a8
Hacktoberfest 2020: Add style improvements for Project Euler Problem 03 (#2917)
* Fix typehints in project_euler/problem01

Squashed commit of the following:

commit 6801d073b31bf702814861cd3b07b634ca295bfa
Author: Archaengel <god11341258@gmail.com>
Date:   Mon Oct 5 16:40:10 2020 -0700

    Fix typehints in project_euler/problem01

commit 29afc3af114abd1b99dc3f7c8fc99128229db131
Author: Archaengel <god11341258@gmail.com>
Date:   Mon Oct 5 15:06:34 2020 -0700

    Add typehints and default argument for project_euler/problem_01

* Add default args, typehints, and expand variable names for PE prob 02

* Add style improvements for first solution of PE Problem 02

* Add default arg and typehints for second solution of PE Problem 02

* Add default arg for third solution of PE Problem 02

* Add style improvements for 1st soln of PE problem 03

* Add default arg and typehints for 2nd soln of PE problem 03

* Add default arg for 3rd soln of PE problem 03

* Remove unnecessary newlines

* Remove unnecessary newlines

* Fix end of file for 2nd soln in PE problem 03
2020-10-06 20:24:39 +05:30
Vladimir Evgrafov
e74adc4a6d
Project Euler Problem 10: style improvements (#2924)
Rename the main solution functions to solution.
Rename prime chec functions to is_prime.
Add default args, typehints, expand variable names.
2020-10-06 17:48:07 +05:30
Edward Nuno
f36a2f621e
Hacktoberfest 2020: Apply style guidelines for Project Euler problem_02 (#2898)
* Fix typehints in project_euler/problem01

Squashed commit of the following:

commit 6801d073b31bf702814861cd3b07b634ca295bfa
Author: Archaengel <god11341258@gmail.com>
Date:   Mon Oct 5 16:40:10 2020 -0700

    Fix typehints in project_euler/problem01

commit 29afc3af114abd1b99dc3f7c8fc99128229db131
Author: Archaengel <god11341258@gmail.com>
Date:   Mon Oct 5 15:06:34 2020 -0700

    Add typehints and default argument for project_euler/problem_01

* Add default args, typehints, and expand variable names for PE prob 02
2020-10-06 10:04:16 +05:30
Utkarsh Chaudhary
a8ad2d10b4
Add Project Euler 120 solution (#2887) 2020-10-06 08:41:15 +05:30
Noah H
a56e548264
Bring problem_30 solution in line with project style guidelines (#2896) 2020-10-06 08:21:39 +05:30
Edward Nuno
edf2cd2b0c
Fix typehints in project_euler/problem01 (#2891)
Squashed commit of the following:

commit 6801d073b31bf702814861cd3b07b634ca295bfa
Author: Archaengel <god11341258@gmail.com>
Date:   Mon Oct 5 16:40:10 2020 -0700

    Fix typehints in project_euler/problem01

commit 29afc3af114abd1b99dc3f7c8fc99128229db131
Author: Archaengel <god11341258@gmail.com>
Date:   Mon Oct 5 15:06:34 2020 -0700

    Add typehints and default argument for project_euler/problem_01
2020-10-06 08:12:16 +05:30
Iqrar Agalosi Nureyza
e040ad2a01
Add a solution for Project Euler 49 (#2702)
* added doctests in modular_exponential.py

* added doctests in modular_exponential.py

* added URL link

* updating DIRECTORY.md

* Add problem 49 solution

* updating DIRECTORY.md

* Fix several mistakes

These fixes are intended to follow the CONTRIBUTING.md

* Move the import statements lower

* Update project_euler/problem_49/sol1.py

Co-authored-by: Dhruv <dhruvmanila@gmail.com>

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Dhruv <dhruvmanila@gmail.com>
2020-10-05 08:27:09 +05:30
Kushagra Bansal
6a395456ee
Created problem_112.py in project_euler (#2532)
* Add files via upload

* Create __init__.py

* Update and rename project_euler/problem_112.py to project_euler/problem_112/sol1.py

* Update project_euler/problem_112/sol1.py

Co-authored-by: Dhruv <dhruvmanila@gmail.com>

* Update sol1.py

* Update sol1.py

* Update project_euler/problem_112/sol1.py

Co-authored-by: Du Yuanchao <shellhub.me@gmail.com>

* Update project_euler/problem_112/__init__.py

Co-authored-by: Du Yuanchao <shellhub.me@gmail.com>

* Update __init__.py

* Update __init__.py

* Update __init__.py

* delete __init__.py content

Co-authored-by: Dhruv <dhruvmanila@gmail.com>
Co-authored-by: Du Yuanchao <shellhub.me@gmail.com>
2020-10-03 16:38:56 +08:00
Dhruv
0a42ae9095
Fix all errors mentioned in pre-commit run (#2512)
* Fix all errors mentioned in pre-commit run:

- Fix end of file
- Remove trailing whitespace
- Fix files with black
- Fix imports with isort

* Fix errors
2020-09-30 10:38:00 +02:00
Dhruv
48357cea5b
Add __init__.py files in all the directories (#2503) 2020-09-28 19:42:36 +02:00
Dhruv
ceacfc6079
Add algorithm for testing Project Euler solutions (#2471)
* Add file for testing Project Euler solutions

* Remove the importlib import

* Update project_euler/solution_test.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Small tweaks to project_euler/solution_test.py

* Test Project Euler solutions through Travis

* Improved testing for Project Euler solutions:

- Renamed file so that it isn't picked up by pytest
- Fail fast on validating solutions through Travis CI

* Update validate_solutions.py

* Use namedtuple for input parameters and answer

- Remove logging
- Remove unnecessary checks for PROJECT_EULER_PATH as Travis CI
  picks up the same path

* Fix flake8 errors: line too long

* Small tweaks to validate_solutions.py

* Add all answers & back to using dictionary

* Using pytest for testing Project Euler solutions

- As we want to fail fast on testing solutions, we need to test using
  this script first before we use tests written by the author.
- As pytest stops testing as soon as it receives a traceback, we need to
  use pytest-subtests to tell pytest to test all the iterations for the
  function with given parameters.

* Print error messages in oneline format

* Separated answers into a separate file:

- Add custom print function to print all the error messages at the
  end of all the tests
- Let Travis skip if this failed

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-09-28 08:18:19 +02:00
Kushagra Bansal
daa1b4d70f
Created problem_97 in project euler (#2476)
* Create __init__.py

* Add files via upload

* Update sol1.py

* Update sol1.py

* Update sol1.py

* Update project_euler/problem_97/sol1.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update sol1.py

* Update project_euler/problem_97/sol1.py

Co-authored-by: Christian Clauss <cclauss@me.com>

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-09-25 11:52:19 +02:00
Dhruv
08eb1efafe
Add solution() for problem 54 of Project Euler (#2472)
* Add solution() for problem 54 of Project Euler

* Add type hints for solution() function
2020-09-24 15:16:55 +02:00
Christian Clauss
9200a2e543
from __future__ import annotations (#2464)
* from __future__ import annotations

* fixup! from __future__ import annotations

* fixup! from __future__ import annotations

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-09-23 13:30:13 +02:00
Du Yuanchao
a1ea76bcf3
Optimization problem_10 in project_euler (#2453)
* optimization for problem09 in project_euler

* added benchmark code

* fixup! Format Python code with psf/black push

* Update project_euler/problem_09/sol1.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* updating DIRECTORY.md

* Update project_euler/problem_09/sol1.py

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2020-09-22 15:15:11 +02:00
Abhinav Anand
718be54dbb
Update sol1.py (#2455) 2020-09-20 21:33:26 +02:00
Dhruv
ea0759dbaa
Create problem_54 in project Euler (#2451)
* Add solution and test files for project euler 54

* Update sol1.py

* updating DIRECTORY.md

* Fix: use proper path to open files

* Commit suggestions:

- Use list comprehension instead of map
- Sort imports using isort

* Changes made as suggested (simplified a lot):

- List and set comprehension instead of itemgetter
- Using enumerate as it's easy to read
- Divided into list of card values and set of card suit as set will
  remove all the duplicate values. So, no need for double indexing.
- Add test for testing multiple calls to five_high_straight function

* Add suggestions and simplified:

- Split generate_random_hands function into two:
  - First will generate a random hand
  - Second, which will be called, will return a generator object

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-09-20 13:52:13 +02:00
Du Yuanchao
2de2267319
Updated problem_06 in Project Euler (#2439)
* * rename variable
* fix type hint
* fix doctest

* added test function

* fixed import error

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-09-17 11:37:53 +02:00
Du Yuanchao
cbbc43ba3a
Updated problem_04 in project_euler (#2427)
* Updated problem_04 in project_euler

* fixup! Format Python code with psf/black push

* That number is larger than our acceptable range.

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2020-09-14 22:33:08 +02:00
Du Yuanchao
4d0a8f2355
Optimized recursive_bubble_sort (#2410)
* optimized recursive_bubble_sort

* Fixed doctest error due whitespace

* reduce loop times for optimization

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-09-10 10:31:26 +02:00
Kushagra Bansal
194b56d376
Created problem_63 in project_euler (#2357)
* Create __init__.py

* Add files via upload

* Update project_euler/problem_63/sol1.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update sol1.py

* Update sol1.py

* Update sol1.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-27 13:40:03 +02:00
Kushagra Bansal
9aa10ca358
Created problem_55 in project_euler (#2354)
* Create __init__.py

* Add files via upload

* Update sol1.py
2020-08-26 13:31:13 +02:00
Kushagra Bansal
402ba7f49a
Created problem_45 in project_euler and Speed Boost for problem_34/sol1.py (#2349)
* Create __init__.py

* Add files via upload

* Update sol1.py

* Update sol1.py

* Update project_euler/problem_45/sol1.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update sol1.py

* Update sol1.py

* Update project_euler/problem_34/sol1.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update project_euler/problem_34/sol1.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update sol1.py

* Update project_euler/problem_34/sol1.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update sol1.py

* Update project_euler/problem_34/sol1.py

Co-authored-by: Christian Clauss <cclauss@me.com>

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-25 13:48:19 +02:00
Kushagra Bansal
5cfc017ebb
Created problem_44 in project_euler (#2348)
* Create __int__.py

* Update and rename project_euler/__int__.py to project_euler/problem_44/__int__.py

* Add files via upload

* Update sol1.py

* Update __int__.py

* Delete __int__.py

* Create __init__.py

* Update project_euler/problem_44/sol1.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update project_euler/problem_44/sol1.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update project_euler/problem_44/sol1.py

Co-authored-by: Christian Clauss <cclauss@me.com>

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-25 09:46:13 +02:00
Kushagra Bansal
ae33419c12
Created problem_46 in project_euler (#2343)
* Create __init__.py

* Add files via upload

* Update sol1.py

* Update sol1.py

* Update project_euler/problem_46/sol1.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update project_euler/problem_46/sol1.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update sol1.py

* exact

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-21 14:09:55 +02:00
Du Yuanchao
0591968947
Optimization and fix bug (#2342)
* * optimization aliquot_sum
* fix bug in average_median

* fixup! Format Python code with psf/black push

* Update maths/average_median.py

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-08-21 14:39:03 +08:00
Kushagra Bansal
456893cb5f
Created problem_43 in project_euler (#2340)
* Create __init__.py

* Add files via upload

* Update sol1.py

* Lose a list()

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-20 17:02:14 +02:00
Kushagra Bansal
9351889fda
Created problem_41 in project_euler (#2334)
* Create __init__.py

* Add files via upload

* Update sol1.py

* Update sol1.py

* Update sol1.py
2020-08-19 12:55:06 +02:00
Kushagra Bansal
9a32f0b46c
Created problem_39 in project_euler (#2330)
* Create __init__.py

* Add files via upload

* Update sol1.py

* Update sol1.py

* Update project_euler/problem_39/sol1.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update sol1.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-18 12:49:02 +02:00
Kushagra Bansal
88341d1727
Created problem_37 in project_euler (#2323)
* Create __init__.py

* Add files via upload

* Update sol1.py

* Update sol1.py

* Update sol1.py

* Update sol1.py

* Update sol1.py

* Update project_euler/problem_37/sol1.py

Co-authored-by: Christian Clauss <cclauss@me.com>

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-17 16:39:58 +02:00
Kushagra Bansal
7e4176ccaf
Created problem_35 in project_euler (#2309)
* Create __init__.py

* Update __init__.py

* Add files via upload

* Update sol1.py

* Update sol1.py to include type hints

* Update CONTRIBUTING.md to fix typo

* Update CONTRIBUTING.md

* Update project_euler/problem_35/sol1.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update project_euler/problem_35/sol1.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update project_euler/problem_35/sol1.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update project_euler/problem_35/sol1.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update project_euler/problem_35/sol1.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update project_euler/problem_35/sol1.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update project_euler/problem_35/sol1.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update sol1.py

* Update sol1.py

* Update sol1.py

* Fix the print(f"string")

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-16 07:52:48 +02:00
Kushagra Bansal
b3ae39249d
Created problem_34 in project_euler (#2305)
* Create __init__.py

* Add files via upload

* Rename solution.py.py to solution.py

* Delete __init__.py

* Update and rename solution.py to sol1.py

* Update sol1.py

* Create __init__.py

* Update __init__.py

* Delete __init__.py

* Add files via upload

* Update __init__.py

* Add #\n

* Update sol1.py

Incorporates the proposed changes

* Update sol1.py

* Update sol1.py

* Update project_euler/problem_34/sol1.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update project_euler/problem_34/sol1.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update project_euler/problem_34/sol1.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update project_euler/problem_34/sol1.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update sol1.py

* Update sol1.py

* Update sol1.py

* Use int(n) instead of floor(n)

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-13 16:52:47 +02:00
Christian Clauss
5f4da5d616
isort --profile black . (#2181)
* updating DIRECTORY.md

* isort --profile black .

* Black after

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-07-06 09:44:19 +02:00
Christian Clauss
8ab84fd794
Only one carriage return (#2155)
* updating DIRECTORY.md

* touch

* fixup! Format Python code with psf/black push

* Update word_frequency_functions.py

* updating DIRECTORY.md

* Update word_frequency_functions.py

* Update lfu_cache.py

* Update sol1.py

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-06-25 19:15:30 +02:00
Mark Moretto
3d4172307f
project_euler/problem_47/sol1.py (#2150)
* Create __init__.py

* Initial commit

Not sure if this should be formatted differently.  I'm open to ideas!

* Completing testing/updates

Ran code through `black`, `flake8`, and `doctest`.  Added some type hints.

`doctest` is finicky on sets, so I had to sort and reformat as set to pass those tests.

* Update project_euler/problem_47/sol1.py

Nice.

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update project_euler/problem_47/sol1.py

Looks good

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update project_euler/problem_47/sol1.py

Okay, this should work.  Thank you for the reminder on map(), filter(), reduce().

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update project_euler/problem_47/sol1.py

My IDE needs a spellchecker.  Or, lighter comment font.

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update project_euler/problem_47/sol1.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update project_euler/problem_47/sol1.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update project_euler/problem_47/sol1.py

This means that `results = run(N)` should be updated to `results = run(n)`, correct?

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update project_euler/problem_47/sol1.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update project_euler/problem_47/sol1.py

Looks good!

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update project_euler/problem_47/sol1.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update project_euler/problem_47/sol1.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update project_euler/problem_47/sol1.py

Works for me! I spent way too much time getting this to pass doctest, so any improvement is welcome.

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update sol1.py

Added some suggested changes from the pull request:
* Updated tests outputs in `unique_prime_factors` function.
* Changed `@lru_cache(maxsize=5)` to `@lru_cache(maxsize=None)`
* Removed duplicate `return` line in `equality` function
* Changed `i` to `base` in run function.
* Added some commentary to `run()` function.
* Replaced `group = list(map(lambda x: base + x, [i for i in range(n)]))` with `group = [base + i for i in range(n)]`

* Update sol1.py

* Trailing whitespace

* Update sol1.py

* Update __init__.py

* Update sol1.py

* Update __init__.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-06-25 12:25:19 +02:00
Christian Clauss
fdc5bee7af
Euler problem 551 sol 1: Reduce McCabe code complexity (#2141)
* Euler problem 551 sol 1: Reduce McCabe code complexity

As discussed in #2128

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-06-22 14:16:12 +02:00
Christian Clauss
9316e7c014
Set the Python file maximum line length to 88 characters (#2122)
* flake8 --max-line-length=88

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-06-16 10:09:19 +02:00
Christian Clauss
1f8a21d727
Tighten up psf/black and flake8 (#2024)
* Tighten up psf/black and flake8

* Fix some tests

* Fix some E741

* Fix some E741

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-05-22 08:10:11 +02:00
Christian Clauss
08c8bb5ad5
Deal with maps (#1945)
* Deal with maps

Try with the search term "pizza" to see why this was done in #1932

* fixup! Format Python code with psf/black push

* Update armstrong_numbers.py

* updating DIRECTORY.md

* Update crawl_google_results.py

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-05-06 03:32:40 +02:00
Sanders Lin
1e84aabaea
Create sol2.py (#1876)
* Create sol2.py

* updating DIRECTORY.md

* Update DIRECTORY.md

* updating DIRECTORY.md

* Update sol2.py

* Update DIRECTORY.md

* updating DIRECTORY.md

* Improve docstrings

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: vinayak <itssvinayak@gmail.com>
Co-authored-by: John Law <johnlaw@linux.com>
2020-05-05 17:27:18 +02:00
Alok Shukla
9b2d65bac1
Solution for Euler Problem 26 (#1939)
* Solution for Euler Problem 26

* Update project_euler/problem_26/sol1.py

typo error fix.

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update project_euler/problem_26/sol1.py

typo error fix

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update project_euler/problem_26/sol1.py

ok to remove, this comes from Pycharm automatically when docstring is added.

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update project_euler/problem_26/sol1.py

ok to remove.

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update project_euler/problem_26/sol1.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update project_euler/problem_26/sol1.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update project_euler/problem_26/sol1.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* now_divide = now_divide * 10 % divide_by_number

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-05-03 22:48:16 +02:00
Christian Clauss
6acd7fb5ce
Wrap lines that go beyond GitHub Editor (#1925)
* Wrap lines that go beyond GiHub Editor

* flake8 --count --select=E501 --max-line-length=127

* updating DIRECTORY.md

* Update strassen_matrix_multiplication.py

* fixup! Format Python code with psf/black push

* Update decision_tree.py

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-05-01 23:36:35 +02:00
Sanders Lin
e5dd2b1eb7
Fix typo in Project Euler sol1.py (#1875) 2020-04-25 23:27:01 +02:00
matkosoric
7f04e5cd34
contribution guidelines checks (#1787)
* spelling corrections

* review

* improved documentation, removed redundant variables, added testing

* added type hint

* camel case to snake case

* spelling fix

* review

* python --> Python # it is a brand name, not a snake

* explicit cast to int

* spaces in int list

* "!= None" to "is not None"

* Update comb_sort.py

* various spelling corrections in documentation & several variables naming conventions fix

* + char in file name

* import dependency - bug fix

Co-authored-by: John Law <johnlaw.po@gmail.com>
2020-03-04 13:40:28 +01:00
Christian Clauss
bfcb95b297
Create codespell.yml (#1698)
* fixup! Format Python code with psf/black push

* Create codespell.yml

* fixup! Format Python code with psf/black push
2020-01-18 13:24:33 +01:00
Sombit Bose
c5b376d52d Solution for problem 30 of Euler Project (#1690)
* Create soln.py

Solution for problem 30 of Euler Project

* Update soln.py

* update soln.py

modified the changes

* if __name__ == "__main__":

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-01-16 15:19:02 +01:00
Christian Clauss
28419cf839 pyupgrade --py37-plus **/*.py (#1654)
* pyupgrade --py37-plus **/*.py

* fixup! Format Python code with psf/black push
2020-01-03 22:25:36 +08:00
Christian Clauss
b838f1042c Fix indentation contains tabs (flake8 E101,W191) (#1573) 2019-11-15 23:05:00 -08:00
Christian Clauss
5df8aec66c
GitHub Action formats our code with psf/black (#1569)
* GitHub Action formats our code with psf/black

@poyea Your review please.

* fixup! Format Python code with psf/black push
2019-11-14 19:59:43 +01:00
jwmneu
52cf668617 add sol3 to project_euler/problem_08 (#1557)
* Add sol3 for project_euler proble_03

* Update sol3.py

add type hint 
remove unused variable

* Format code with psf/black

* add sol3 to project_euler/problem_08, modify the stepsize of the loop,will be faster than sol1
2019-11-14 19:08:07 +01:00
jwmneu
ad2db80f8a Add sol3 for project_euler problem_03 (#1553)
* Add sol3 for project_euler proble_03

* Update sol3.py

add type hint 
remove unused variable

* Format code with psf/black
2019-11-07 09:37:28 +01:00
vinayak
0e3357ae35
added solution 1 for problem_99 in project_euler (#1545)
* Create sol1.py

* Create __init__.py

* Update sol1.py

* corrected range

* Add files via upload

* Update DIRECTORY.md

* Create sol1.py

* Update sol1.py

* Create __init__.py

* Update DIRECTORY.md

* Delete isotonic.py

* Update sol1.py

* Problem_27_project_euler

* project_euler/Problem_27/sol1.py

* project_euler/Problem_27/sol1.py

* project_euler/problem_27/

* project_euler/problem_27

* project_euler/problem_27

* update sol1 of Euler Problem 27 solution script Added

* Remove slow test, wrap long comments, format with psf/black

* Delete __init__.py

* Add type hints

* Add doctests to function is_prime()

* Rename project_euler/problem_27/project_euler/problem_27/sol1.pysol1.py to project_euler/problem_27/problem_27_sol1.py

* Added Problem 33

* added solution 1 for problem_99

* update added solution 1 for problem_99

* update

* Update sol1.py
2019-11-01 13:57:16 +05:30
Charley
80e1c8748a Added Problem 33 (#1440)
* Create sol1.py

* Create __init__.py

* Update sol1.py

* corrected range

* Update sol1.py
2019-10-31 17:50:39 +05:30
RitwickGhosh
8a5633a233 Euler Problem 27 solution script Added (#1466)
* Add files via upload

* Update DIRECTORY.md

* Create sol1.py

* Update sol1.py

* Create __init__.py

* Update DIRECTORY.md

* Delete isotonic.py

* Update sol1.py

* Problem_27_project_euler

* project_euler/Problem_27/sol1.py

* project_euler/Problem_27/sol1.py

* project_euler/problem_27/

* project_euler/problem_27

* project_euler/problem_27

* update sol1 of Euler Problem 27 solution script Added

* Remove slow test, wrap long comments, format with psf/black

* Delete __init__.py

* Add type hints

* Add doctests to function is_prime()

* Rename project_euler/problem_27/project_euler/problem_27/sol1.pysol1.py to project_euler/problem_27/problem_27_sol1.py
2019-10-31 08:19:10 +01:00
Suad Djelili
39c40e7e40 added solution 3 for problem_25 (#1478)
* added solution 4 for problem_20

* added solution 3 for problem_25
2019-10-28 00:52:34 +01:00
Suad Djelili
a7078d7c27 added solution 4 for problem_20 (#1476) 2019-10-27 19:07:04 +01:00
Ankur Chattopadhyay
7592cba417 psf/black code formatting (#1421)
* added sol3.py for problem_20

* added sol4.py for problem_06

* ran `black .` on `\Python`
2019-10-22 19:13:48 +02:00
Ankur Chattopadhyay
11e2207182 Project Euler problems 06, 20 (#1419)
* added sol3.py for problem_20

* added sol4.py for problem_06
2019-10-22 18:02:03 +02:00
Suad Djelili
8b572e6cfd added solution 7 for problem_01 (#1416)
* added solution 7 for problem_01

* added solution 5 for problem_02
2019-10-22 09:31:17 +02:00
Kumar Shivam
e0158c2c30 fixed project eular readme (#1391) 2019-10-18 23:52:32 +02:00
aritrartira
28b964c9b5 Added missing problem statements (#1364) 2019-10-18 06:46:13 +02:00
William Zhang
9eac17a408 psf/black code formatting (#1277) 2019-10-05 10:14:13 +05:00
Kaushik Amar Das
07f04a2e55 adding jaccard similarity (#1270)
* adding jaccard similarity

* renaming files. zeebus! what an headache
2019-10-04 09:59:45 +02:00
Simon Landry
309204a581 Add problem 42 solution (#1259) 2019-10-03 22:48:53 +02:00
Simon Landry
6e69208666 Add problem 32 solution (#1257) 2019-10-03 22:47:39 +02:00
Simon Landry
d28fc71202 Add problem18 solution (#1260) 2019-10-03 22:47:08 +02:00
Simon Landry
f970c73061 Add problem 23 solution (#1261) 2019-10-03 22:08:25 +02:00
Simon Landry
3c3f92db53 Add problem 67 solution (#1170) 2019-09-08 10:40:07 +02:00
b63
d567a9eb8c solution to problem 551 from project euler (#1164)
* solution to problem 551 from project euler

* renamed variables, and added more comments to improve readabilty
2019-09-01 08:07:31 +02:00
Christian Clauss
47a9ea2b0b
Simplify code by dropping support for legacy Python (#1143)
* Simplify code by dropping support for legacy Python

* sort() --> sorted()
2019-08-19 15:37:49 +02:00
Alok Shukla
8eab2f17f4 Solution for Problem Euler 56 (#1131)
* Solution for Euler 56

* Adding Type and Doctest as per guideline

* removing unused import

* correcting the way type check works
2019-08-13 19:16:11 +02:00
vinayak
4a5589f4fc project_euler/problem_10 (#1089)
* project_euler/problem_10

* update project_euler/problem_10

* update project_euler/problem_10

* Negative user tests added.
2019-07-31 13:20:32 +02:00
Christian Clauss
3c8e9314b6 Travis CI: Add a flake8 test for unused imports (#1038) 2019-07-25 13:19:00 +05:30
Bruno Simas Hadlich
9fcfe6a02b Commented doctests that were causing slowness at Travis. #2 (#1041)
* Added doctest and more explanation about Dijkstra execution.

* tests were not passing with python2 due to missing __init__.py file at number_theory folder

* Removed the dot at the beginning of the imported modules names because 'python3 -m doctest -v data_structures/hashing/*.py' and 'python3 -m doctest -v data_structures/stacks/*.py' were failing not finding hash_table.py and stack.py modules.

* Moved global code to main scope and added doctest for project euler problems 1 to 14.

* Added test case for negative input.

* Changed N variable to do not use end of line scape because in case there is a space after it the script will break making it much more error prone.

* Added problems description and doctests to the ones that were missing. Limited line length to 79 and executed python black over all scripts.

* Changed the way files are loaded to support pytest call.

* Added __init__.py to problems to make them modules and allow pytest execution.

* Added project_euler folder to test units execution

* Changed 'os.path.split(os.path.realpath(__file__))' to 'os.path.dirname()'

* Added Burrows-Wheeler transform algorithm.

* Added changes suggested by cclauss

* Fixes for issue 'Fix the LGTM issues #1024'.

* Added doctest for different parameter types and negative values.

* Fixed doctest issue added at last commit.

* Commented doctest that were causing slowness at Travis.

* Added comment with the reason for some doctest commented.

* pytest --ignore

* Added tests execution again.

* Had forgotten to add comment to file project_euler/problem_09/sol3.py
2019-07-19 06:33:28 +02:00
Bruno Simas Hadlich
f7ac8b5ed0 Commented doctests that were causing slowness at Travis. (#1039)
* Added doctest and more explanation about Dijkstra execution.

* tests were not passing with python2 due to missing __init__.py file at number_theory folder

* Removed the dot at the beginning of the imported modules names because 'python3 -m doctest -v data_structures/hashing/*.py' and 'python3 -m doctest -v data_structures/stacks/*.py' were failing not finding hash_table.py and stack.py modules.

* Moved global code to main scope and added doctest for project euler problems 1 to 14.

* Added test case for negative input.

* Changed N variable to do not use end of line scape because in case there is a space after it the script will break making it much more error prone.

* Added problems description and doctests to the ones that were missing. Limited line length to 79 and executed python black over all scripts.

* Changed the way files are loaded to support pytest call.

* Added __init__.py to problems to make them modules and allow pytest execution.

* Added project_euler folder to test units execution

* Changed 'os.path.split(os.path.realpath(__file__))' to 'os.path.dirname()'

* Added Burrows-Wheeler transform algorithm.

* Added changes suggested by cclauss

* Fixes for issue 'Fix the LGTM issues #1024'.

* Added doctest for different parameter types and negative values.

* Fixed doctest issue added at last commit.

* Commented doctest that were causing slowness at Travis.

* Added comment with the reason for some doctest commented.

* pytest --ignore
2019-07-19 00:34:29 +02:00
Bruno Simas Hadlich
f438440ac5 Fixes for issue "Fix the LGTM issues #1024" (#1034)
* Added doctest and more explanation about Dijkstra execution.

* tests were not passing with python2 due to missing __init__.py file at number_theory folder

* Removed the dot at the beginning of the imported modules names because 'python3 -m doctest -v data_structures/hashing/*.py' and 'python3 -m doctest -v data_structures/stacks/*.py' were failing not finding hash_table.py and stack.py modules.

* Moved global code to main scope and added doctest for project euler problems 1 to 14.

* Added test case for negative input.

* Changed N variable to do not use end of line scape because in case there is a space after it the script will break making it much more error prone.

* Added problems description and doctests to the ones that were missing. Limited line length to 79 and executed python black over all scripts.

* Changed the way files are loaded to support pytest call.

* Added __init__.py to problems to make them modules and allow pytest execution.

* Added project_euler folder to test units execution

* Changed 'os.path.split(os.path.realpath(__file__))' to 'os.path.dirname()'

* Added Burrows-Wheeler transform algorithm.

* Added changes suggested by cclauss

* Fixes for issue 'Fix the LGTM issues #1024'.

* Added doctest for different parameter types and negative values.

* Fixed doctest issue added at last commit.
2019-07-18 19:05:14 +02:00
Jigyasa G
4658f4a49e lgtm fixes (#1032)
* adding sum of subsets

* lgtm fixes
2019-07-18 18:47:15 +08:00
Bruno Simas Hadlich
267b5eff40 Added doctest and more explanation about Dijkstra execution. (#1014)
* Added doctest and more explanation about Dijkstra execution.

* tests were not passing with python2 due to missing __init__.py file at number_theory folder

* Removed the dot at the beginning of the imported modules names because 'python3 -m doctest -v data_structures/hashing/*.py' and 'python3 -m doctest -v data_structures/stacks/*.py' were failing not finding hash_table.py and stack.py modules.

* Moved global code to main scope and added doctest for project euler problems 1 to 14.

* Added test case for negative input.

* Changed N variable to do not use end of line scape because in case there is a space after it the script will break making it much more error prone.

* Added problems description and doctests to the ones that were missing. Limited line length to 79 and executed python black over all scripts.

* Changed the way files are loaded to support pytest call.

* Added __init__.py to problems to make them modules and allow pytest execution.

* Added project_euler folder to test units execution

* Changed 'os.path.split(os.path.realpath(__file__))' to 'os.path.dirname()'
2019-07-17 01:09:53 +02:00