Commit Graph

207 Commits

Author SHA1 Message Date
Naveen Namani
11a15cc584
Add solution for Project Euler problem 67 (#5519)
* New solution for Euler problem 67

A faster and memory efficient solution based on the template of sol1.py.
Modified the solution to be more memory efficient while reading and generating the array
and during the solution finding.
No conditions and straightforward logic.

* added return type hint

* Update project_euler/problem_067/sol2.py

Preferring comprehensions over map

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

* Update sol2.py

Self explanatory variable names

* Updated sol2 to problem 067 in directory

* Update project_euler/problem_067/sol2.py

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

* Update project_euler/problem_067/sol2.py

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

* Fixed extra line

Co-authored-by: Christian Clauss <cclauss@me.com>
2021-10-28 19:27:14 +02:00
Prakhar Gurunani
329feb4928
Add Project Euler Problem 078 solution 01 (#5565)
* Create sol1.py

* updating DIRECTORY.md

* Create __init__.py

* Add docstring

* Reformat with black

* Fix flake8 issues

* Add EOL

* Fix formatting issues

* Add docstring

* Add func return type

* Change return type

* Remove test print statement

* Reformat code

* Fix return types

* Break loop

* Update doctest sol

* Update project_euler/problem_078/sol1.py

Co-authored-by: John Law <johnlaw.po@gmail.com>

* Added doctest and changed return type

* Add int()

* Fix flake8 issues

* Use argument instead of fixed constant

* Update sol1.py

* fix sol1.py

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: John Law <johnlaw.po@gmail.com>
2021-10-27 17:19:04 +08:00
Srishtik Bhandarkar
b4036b70f1
Add solution for probelm_686 of project_euler (#5480)
* Added solution for probelm_686 of project_euler

* Changed documentation and formatting.

* Added ref link to optimization logic

* Update project_euler/problem_686/sol1.py

Co-authored-by: John Law <johnlaw.po@gmail.com>

Co-authored-by: John Law <johnlaw.po@gmail.com>
2021-10-27 01:10:15 +08:00
Maxim Smolskiy
b55da04602
Improve Project Euler problem 058 solution 1 (#4782)
* Fix typo

* Improve solution

* Retest

* Replace n with number
2021-10-25 16:07:10 +08:00
Maxim Smolskiy
5f7bb3e9f7
Improve Project Euler problem 034 solution 1 (#5165) 2021-10-25 16:03:22 +08:00
Marcel Kuhmann
5772d0734b
fix dead link (#5572) 2021-10-24 18:44:15 +02:00
John Law
c0acfd46cb
Fix factorial issues (#5496)
* updating DIRECTORY.md

* pass integer to `math.factorial` in `project_euler/problem_015`

* remove duplicated factorial function

* updating DIRECTORY.md

* Update maths/factorial_iterative.py

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

* Update factorial_iterative.py

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2021-10-21 15:06:32 +08:00
John Law
4bf2eedd3c
[mypy] fix mypy error in Project Euler Problem 092 solution 1 (#5357)
* fix mypy error

* updating DIRECTORY.md

* simplify code

* run black

* fix doc consistency

* Fix doc

* fix doc

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-10-17 08:07:45 +02:00
Srishtik Bhandarkar
7ef2e4d1d0
Add Project Euler Problem 092 (#5091)
* adde solution to problem 092

* added solution to problem 092

* fixed the pre-comit shebang issue
2021-10-17 01:08:41 +08:00
Joyce
bcfca67faa
[mypy] fix type annotations for all Project Euler problems (#4747)
* [mypy] fix type annotations for problem003/sol1 and problem003/sol3

* [mypy] fix type annotations for project euler problem007/sol2

* [mypy] fix type annotations for project euler problem008/sol2

* [mypy] fix type annotations for project euler problem009/sol1

* [mypy] fix type annotations for project euler problem014/sol1

* [mypy] fix type annotations for project euler problem 025/sol2

* [mypy] fix type annotations for project euler problem026/sol1.py

* [mypy] fix type annotations for project euler problem037/sol1

* [mypy] fix type annotations for project euler problem044/sol1

* [mypy] fix type annotations for project euler problem046/sol1

* [mypy] fix type annotations for project euler problem051/sol1

* [mypy] fix type annotations for project euler problem074/sol2

* [mypy] fix type annotations for project euler problem080/sol1

* [mypy] fix type annotations for project euler problem099/sol1

* [mypy] fix type annotations for project euler problem101/sol1

* [mypy] fix type annotations for project euler problem188/sol1

* [mypy] fix type annotations for project euler problem191/sol1

* [mypy] fix type annotations for project euler problem207/sol1

* [mypy] fix type annotations for project euler problem551/sol1
2021-10-12 00:33:44 +08:00
Maxim Smolskiy
d654806eae
Improve Project Euler problem 112 solution 1 (#4808) 2021-10-06 22:11:50 +08:00
Maxim Smolskiy
629369a34f
Improve Project Euler problem 203 solution 1 (#4807) 2021-10-06 22:11:15 +08:00
Maxim Smolskiy
66a528b171
Improve Project Euler problem 014 solution 2 (#4752) 2021-09-24 02:55:18 +08:00
Maxim Smolskiy
a7b9e28bc3
Improve Project Euler problem 009 solution 1 (#4749)
* Improve solution

* Uncomment code that has been commented due to slow execution affecting Travis
2021-09-21 13:28:27 +02:00
Maxim Smolskiy
01d58562cc
Fix typos in Project Euler problem 034 solution 1 (#4748)
* Fix comment

* Fix output
2021-09-18 21:33:03 +02:00
Christian Clauss
cecf43d648
Pyupgrade to Python 3.9 (#4718)
* Pyupgrade to Python 3.9

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-09-07 13:37:03 +02:00
fpringle
8c13a7786f
feat: add solution for Project Euler problem 144 (#4280)
* Added solution for Project Euler problem 144

* updating DIRECTORY.md

* Better variable names

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-07-08 14:05:10 +05:30
Elisha Hollander
e7e6cbfb8f
refactor: Remove "redefinition" of dict element (#4309) 2021-04-04 09:25:57 +05:30
fpringle
89a43c81e5
feat: Add solution for Project Euler Problem 121 (#4261)
* Added solution for Project Euler problem 121

* Updated typing for 3.9

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-03-20 11:29:48 +05:30
fpringle
ecf9b8164f
Added solution for Project Euler problem 109 (#4080)
* Added solution for Project Euler problem 109

* New subscriptable builtin types

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-03-06 18:59:52 +05:30
fpringle
80f5213df5
Add solution for Project Euler problem 107 (#4066)
* Added solution for Project Euler problem 107

* Doctests and better variable names

* Type hints

* Small edits

* Forward reference for typing hint

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-12-28 13:21:02 +05:30
fpringle
0ccb213c11
Add solution for Project Euler problem 102 (#4051)
* Added solution for Project Euler problem 102

* Got rid of map functions

* Snake case variable names

* Type hints

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-12-23 23:18:19 +05:30
fpringle
2ff2ccbeec
Add solution for Project Euler problem 101 (#4033)
* Added solution for Project Euler problem 101

* Got rid of map functions

* updating DIRECTORY.md

* Better function/variable names

* Better variable names

* Type hints

* Doctest for nested function

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-12-22 17:32:31 +05:30
sharmapulkit04
00f22a9970
Add solution for Project Euler problem 135 (#4035) 2020-12-19 11:46:15 +05:30
fpringle
ae8a5f8675
Add solution for Project Euler problem 59 (#4031)
* Added solution for Project Euler problem 59

* updating DIRECTORY.md

* Formatting, type hints, no more evil map functions

* Doctests

* Added doctests for Project Euler problem 59

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-12-13 16:39:52 +05:30
fpringle
a6f6eb2649
Add solution for Project Euler problem 86 (#4025)
* Added solution for Project Euler problem 86

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-12-12 10:49:35 +05:30
fpringle
75759fae22
Add solution for Project Euler problem 085 (#4024)
* Added solution for Project Euler problem 085.

* updating DIRECTORY.md

* Minor tweaks to Project Euler problem 85

* Variable comments for project euler problem 85

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-12-10 18:48:17 +05:30
fpringle
b1801398ec
Add Project Euler Problem 180 (#4017)
* Added solution for Project Euler problem 180

* Fixed minor details in Project Euler problem 180

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-12-09 16:44:51 +05:30
fpringle
1e1708b8a1
Added solution for Project Euler problem 77 (#3132)
* Added solution for Project Euler problem 77.

* Update docstrings, doctest, type annotations and 0-padding in directory name. Reference: #3256

* Implemented lru_cache, better type hints, more doctests for problem 77

* updating DIRECTORY.md

* updating DIRECTORY.md

* Added solution for Project Euler problem 77. Fixes: 2695

* Update docstrings, doctest, type annotations and 0-padding in directory name. Reference: #3256

* Implemented lru_cache, better type hints, more doctests for problem 77

* better variable names

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-11-27 21:38:14 +05:30
Cory Metcalfe
b55e132b80
Add solution for Project Euler: Problem 89 (#2948)
* add solution for euler problem 89

* updates to accommodate euler solution guideline updates

* use more descriptive vars

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-11-21 10:59:29 +05:30
fpringle
c938e7311f
Added solution for Project Euler problem 129. (#3113)
* Added solution for Project Euler problem 129. 
* Added doctest for solution() in project_euler/problem_129/sol1.py
* Update formatting. Reference: #3256 
* More descriptive function and variable names, more doctests.
2020-11-21 08:22:26 +05:30
Peter Yao
28d33f4b2d
Project Euler 70 Solution (#3041)
* Add solution for Project Euler 70, Fixes: #2695

* Remove parameter from solution()

* Add tests for all functions, add fstring and positional arg for solution()

* Rename directory to 070

* Move up explanation to module code block

* Move solution() below helper functions, rename variables

* Remove whitespace from defining min_numerator

* Add whitespace

* Improve type hints with typing.List

Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
2020-11-21 08:12:07 +05:30
Michael D
d0bc9e268d
Add solution for Project Euler problem 188 (#2880)
* Project Euler problem 188 solution

* fix superscript notation

* split out modexpt() function, and rename parameters

* Add some more doctest, and add type hints

* Add some reference links

* Update docstrings and mark helper function private

* Fix doctests and remove/improve redundant comments

* fix as per style guide
2020-11-21 07:37:47 +05:30
tacitvenom
83b8b3c141
Fixes: #3869: Optimize CI runtime of Project Euler's Problem 74's Solution 2 (#3893)
* Fixes: #3869: Optimize Project Euler's Problem 74's  Solution 2

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-11-20 09:44:08 +05:30
Simon Landry
686d837d3e
Add project euler problem 50 (#3016)
* Add project euler problem 50

* Apply format changes

* Descriptive function/parameter name and type hints

Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
2020-11-08 08:26:10 +05:30
Ravi Kandasamy Sundaram
c8db6a208b
Add solution for Project Euler problem 123 (#3072)
Name: Prime square remainders

Let pn be the nth prime: 2, 3, 5, 7, 11, ..., and
let r be the remainder when (pn−1)^n + (pn+1)^n is divided by pn^2.

For example, when n = 3, p3 = 5, and 43 + 63 = 280 ≡ 5 mod 25.
The least value of n for which the remainder first exceeds 10^9 is 7037.

Find the least value of n for which the remainder first exceeds 10^10.

Reference: https://projecteuler.net/problem=123

reference: #2695

Co-authored-by: Ravi Kandasamy Sundaram <rkandasamysundaram@luxoft.com>
2020-11-06 22:25:02 +05:30
Shikhar Rai
29d0fbb0e0
HACKTOBERFEST - Added solution to Euler 64. (#3706)
* Added solution to Euler 64.

Added Python solution to Project Euler Problem 64.
Added a folder problem_064.
Added __init__.py file.
Added sol1.py file.

* Update sol1.py

Made formatting changes as mentioned by pre-commit

* Update sol1.py

Minor changes to variable naming and function calling as mentioned by @ruppysuppy

* Update sol1.py

Changes to function call as mentioned by @cclauss
2020-11-03 08:48:14 +05:30
Fernando Benjamín PÉREZ MAURERA
ff00bfa0ab
Added a solution for Project Euler Problem 203 "Squarefree Binomial Coefficients" (#3513)
* Added a solution for Project Euler Problem 203 (https://projecteuler.net/problem=203)

* Simplified loop that calculates the coefficients of the Pascal's Triangle. Changes based on review suggestion.

* Moved get_squared_primes_to_use function outside the get_squarefree function and fixed a failing doctest with the former.
2020-11-03 07:51:13 +05:30
Peter Yao
61cb921d87
Project Euler 206 Solution (#3829)
* Readd Project Euler 206 solution for issue #2695, dupe of pull request #3042

* Add PE 206 to directory

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-11-02 23:24:20 +05:30
GGn0
d8f573c0fb
Add solution to problem 74 (#3110)
* Add solution to problem 74

* Fix typo

* Edit unnecessary comment

* Rename folder, add default params in solution()

* Rename file to solve conflicts

* Fix doctests
2020-11-01 21:12:21 +08:00
Akash Kumar
d3ead53882
Added solution to Project Euler problem 301 (#3343)
* Added solution to Project Euler problem 301

* Added newline to end of file

* Fixed formatting and tests

* Changed lossCount to loss_count

* Fixed default parameter value for solution

* Removed helper function and modified print stmt

* Fixed code formatting

* Optimized solution from O(n^2) to O(1) constant time

* Update sol1.py
2020-11-01 16:27:48 +05:30
PetitNigaud
99adac0eb1
Add first solution for Project Euler Problem 207 (#3522)
* add solution to Project Euler problem 206

* Add solution to Project Euler problem 205

* updating DIRECTORY.md

* updating DIRECTORY.md

* Revert "Add solution to Project Euler problem 205"

This reverts commit 64e3d36cab.

* Revert "add solution to Project Euler problem 206"

This reverts commit 53568cf4ef.

* add solution for project euler problem 207

* updating DIRECTORY.md

* add type hint for output of helper function

* Correct default parameter value in solution

* use descriptive variable names and remove problem solution from doctest Fixes: #2695

Co-authored-by: nico <esistegal-aber@gmx.de>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-29 12:34:42 +05:30
fpringle
9971f981a1
Added solution for Project Euler problem 87. (#3141)
* Added solution for Project Euler problem 87. Fixes: #2695

* Update docstring and 0-padding in directory name. Reference: #3256
2020-10-29 12:19:33 +05:30
sharmapulkit04
e172a8b08b
Hacktoberfest: Added first solution to Project Euler problem 58 (#3599)
* Added solution to problem 58

* Update sol1.py

Co-authored-by: John Law <johnlaw.po@gmail.com>
2020-10-29 10:03:55 +08:00
John Law
a5aef147e9
Fix Project Euler Readme (#3754)
* Fix Project Euler Readme

* updating DIRECTORY.md

* Update CONTRIBUTING.md

* spacing

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-26 21:18:57 +05:30
Ayoub Chegraoui
3a191d9a7c
Add solution to Project Euler problem 81 (#3408)
* Add solution to problem 81 - project euler

* Update project_euler/problem_081/sol1.py

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

* Update project_euler/problem_081/sol1.py

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

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-10-25 09:36:31 +05:30
Michael D
98e9d6bdb6
Fix style of the first ten solutions for Project Euler (#3242)
* Fix style of the first ten solutions for Project Euler

- Unify the header docstring, and add reference URLs to wikipedia
  or similar
- Fix docstrings to be properly multilined
- Add newlines where appropriate
- Add doctests where they were missing
- Remove doctests that test for the correct solution
- fix obvious spelling or grammar mistakes in comments and
  exception messages
- Fix line endings to be UNIX. This makes two of the files seem
  to have changed completely
- no functional changes in any of the solutions were done
  (except for the spelling fixes mentioned above)

* Fix docstrings and main function as per Style Guide
2020-10-25 08:53:16 +05:30
Dhruv Manilawala
b97529dd88
Move validate_solutions and add durations flag to pytest.ini (#3704)
* Move PE validate_solutions to scripts/ directory

* Update pytest.ini file with durations settings

* Remove codespell and autoblack workflow file

* Dependent changes to test config files

* Update pytest.ini
2020-10-24 19:07:33 +05:30
fpringle
409438d250
Add solution for Project Euler problem 38. (#3115)
* Added solution for Project Euler problem 38. Fixes: #2695

* Update docstring and 0-padding in directory name. Reference: #3256

* Renamed is_9_palindromic to is_9_pandigital.

* Changed just-in-case return value for solution() to None.

* Moved exmplanation to module-level docstring and deleted unnecessary import
2020-10-24 08:12:15 +05:30
Peter Yao
20260d2b9c
Add Project Euler 65 Solution (#3035)
* Add solution for Project Euler 65,

* Add URL to problem 65 and don't pass in parameter to solution()

* Remove solution() tests

* Add tests for solution(), add fstring and positional arg for solution

* Rename directory and problem number to 065

* Remove directory

* Move up explanation to module code block

* Move solution() below helper function, rename variables
2020-10-24 07:55:15 +05:30