Commit Graph

223 Commits

Author SHA1 Message Date
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
Christian Clauss
9b95e4f662
Pyupgrade to python3.8 (#3616)
* Upgrade to Python 3.8 syntax

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-21 12:46:14 +02:00
Benjamin Smith
58875674da
Project Euler 57 - Square root convergents (#3259)
* include solution for problem 57

* fix line to long errors

* update filenames and code to comply with new regulations

* more descriptive local variables
2020-10-16 21:17:35 +05:30
fpringle
9643d3060d
Add solution for Project Euler problem 75. (#3129)
* Added solution for Project Euler problem 75. 

* Added doctest for solution() in project_euler/problem_75/sol1.py

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

* More descriptive variable names

* Moved solution explanation to module-level docstring
2020-10-16 16:00:45 +05:30
fpringle
b74f3a8b48
Add solution for Project Euler problem 91. (#3144)
* Added solution for Project Euler problem 91. Reference: #2695

* Added doctest for solution() in project_euler/problem_91/sol1.py

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

* Update sol1.py

Co-authored-by: Dhruv <dhruvmanila@gmail.com>
2020-10-16 15:44:06 +05:30
fpringle
b96e6c7075
Add solution for Project Euler problem 174. (#3078)
* Added solution for Project Euler problem 174. 

* Fixed import order and removed executable permission from sol1.py

* Update docstrings, doctests, and annotations. Reference: #3256

* Update docstring

* Update sol1.py

Co-authored-by: Dhruv <dhruvmanila@gmail.com>
2020-10-16 15:14:09 +05:30
fpringle
d8f5b31fab
Add solution for Project Euler problem 72 (#3122)
* Added solution for Project Euler problem 72.

* Update type annotations and 0-padding of the directory name. Reference: #3256

* Rename sol1.py to sol2.py

* Added newline at the end of sol2.py

* Revert sol1.py
2020-10-16 15:12:51 +05:30
fpringle
316fc41d6d
Add solution for Project Euler problem 74. (#3125)
* Added solution for Project Euler problem 74. Fixes: #2695

* Added doctest for solution() in project_euler/problem_74/sol1.py

* Update docstrings and 0-padding of directory name. Reference: #3256
2020-10-16 00:28:15 +05:30
fpringle
9482f6a5a9
Add solution for Project Euler problem 173. (#3075)
* Added solution for Project Euler problemm problem 173. #2695

* Added docstring

* Update formatting, doctest and annotations. Reference: #3256
2020-10-15 15:36:40 +05:30
fpringle
a119005135
Add solution for Project Euler problem 113 (#3109)
* Added solution for Project Euler problem 113. #2695

* Updated formatting and doctests. Reference: #3256
2020-10-15 15:29:53 +05:30
Dhruv
44254cf112
Rename Project Euler directories and other dependent changes (#3300)
* Rename all Project Euler directories:

Reason:
The change was done to maintain consistency throughout the directory
and to keep all directories in sorted order.

Due to the above change, some config files had to be modified:
'problem_22` -> `problem_022`

* Update scripts to pad zeroes in PE directories
2020-10-15 12:43:28 +05:30
Dhruv
2d7e08ef83
Update README.md for Project Euler (#3256)
* Update README.md for Project Euler

* Add link to solution template

* Add newlines for better separation

* Add __name__ == __main__ block in template

* Apply suggestions from code review

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

* Improve introduction part

Co-authored-by: John Law <johnlaw.po@gmail.com>
2020-10-15 09:47:19 +05:30
Peter Yao
671ab1d863
Project Euler 62 Solution (#3029)
* Add solution for Project Euler 62

* Add doctests and annotate function params and return values for get_digits()

* Add extra newline between functions to fix flake8 errors

* Add extra newlines between function names

* Add missing return type for solution()

* Remove parenthesis from if statement

* Remove parentheses from while loop

* Add to explanation and fix second Travis build

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

* Remove input param when calling solution()

* Remove test case for the answer
2020-10-15 09:13:39 +05:30
Dhruv
29b32d3553
Improve validate solutions script & fix pre-commit error (#3253)
* Trying to time every solution

* Proposal 2 for timing PE solutions:

- Use pytest fixture along with --capture=no flag to print out the
  top DURATIONS slowest solution at the end of the test sessions.
- Remove the print part and try ... except ... block from the test
  function.

* Proposal 3 for timing PE solutions:

Completely changed the way I was performing the tests. Instead of
parametrizing the problem numbers and expected output, I will
parametrize the solution file path.

Steps:
- Collect all the solution file paths
- Convert the paths into a Python module
- Call solution on the module
- Assert the answer with the expected results

For assertion, it was needed to convert the JSON list object to
Python dictionary object which required changing the JSON file itself.

* Add type hints for variables

* Fix whitespace in single_qubit_measure
2020-10-13 15:41:12 +05:30
Simon Landry
50d7ed8417
Add project euler problem 51 (#3018)
* Add project euler problem 51

* Apply review suggestions
2020-10-12 22:40:29 +05:30
Utkarsh Chaudhary
8f8d39d191
Add a solution to Project Euler 72 (#2940)
* Added Problem 72

* Removed args from solution()

* Incorporated the suggested changes
2020-10-12 19:46:15 +05:30
Kasper Primdal Lauritzen
b6b025f25a
Fix docstring for Euler problem 11, solution 1 (#3228)
Docstring must have been leftover from some FizzBuzz method.
Now it describes the actual code.
2020-10-12 19:44:45 +05:30
Kasper Primdal Lauritzen
7b60cea490
Fix docstring for Euler problem 11, solution 2 (#3227) 2020-10-12 16:58:46 +05:30
Dhruv
69f9283825
Start running validate_solutions script for Travis CI (#3215)
* Removed print error_msgs at the end of test:

This was done only to reduce the message clutter produced by 60
failing tests. As that is fixed, we can produce the traceback in
short form and allow pytest to print the captured error message
output at the end of test.

* Start validate_solutions script for Travis CI

I am separating out the solution testing and doctest as validating
the solutions for the current number of solutions present is
taking 2 minutes to run.
2020-10-12 11:29:39 +05:30
sarthaka1310
d02f6bbfbd
Added solution to Project Euler 69 (#2934)
* Added solution to Project Euler 69

* Accept edits from code review

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

* Added doctests

* Renaming and exception handling

* Apply suggestions from code review

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

* Edited mistake.

Co-authored-by: formal-acc <sarthak.agrawal@research.iiit.ac.in>
Co-authored-by: Dhruv <dhruvmanila@gmail.com>
2020-10-11 23:38:30 +05:30
Simon Landry
60f9895685
Fixes: #3163 - Add new solution for problem 234 (#3177)
* Fixes: #3163 - Add new solution for problem 234

* Apply review suggestions
2020-10-11 23:16:16 +05:30
Michael D
f029fcef7b
Add solution for Project Euler problem 191 (#2875)
* Project Euler problem 191 solution

* Add type hints and reference links

* Address requested changes

- update documentation
- split out helper function but mark it with an underscore
- remove redundant comments or make them more explicit/helpful

* Address requested changes
2020-10-11 17:59:27 +05:30
Ravi Kandasamy Sundaram
2b5b2c6304
Added solution for Project Euler problem 119 (#2931)
Name: Digit power sum

Problem Statement: The number 512 is interesting because it is equal to the sum of its digits raised to some power: 5 + 1 + 2 = 8, and 83 = 512. Another example of a number with this property is 614656 = 284.
We shall define an to be the nth term of this sequence and insist that a number must contain at least two digits to have a sum.
You are given that a2 = 512 and a10 = 614656.
Find a30

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

reference: #2695

Co-authored-by: Ravi Kandasamy Sundaram <rkandasamysundaram@luxoft.com>
2020-10-10 23:29:02 +05:30
Dhruv
501a2ff430
[Project Euler] Fix code style for multiple problems (#3094)
* Fix code style for Project Euler problems:

- 13, 17, 21
- Default args
- Type hints
- File path

* Fix code style for multiple problems

* Made suggested changes
2020-10-10 21:23:17 +05:30
Sandeep Gupta
c07b82fa63
Add Project Euler Problem 80 (#2885)
* adding solution to problem 80

* updating DIRECTORY.md

* fixing spell check

* updating sol as per comments

* Add reference link to the problem

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Dhruv <dhruvmanila@gmail.com>
2020-10-10 17:06:25 +05:30
Carlos Meza
927e14e7f2
Cleanup Project Euler Problem 01 (#2900)
* mv str statement into docstr

* rename var to avoid redefining builtin

* clean up module docstr
2020-10-10 11:03:00 +05:30
fpringle
c83e4b77c5
Added solution for Project Euler problem 125 (#3073)
* Added solution for Project Euler problem 125

* Fixed typos
2020-10-09 22:41:00 +05:30
fa1l
10fe9d9be4
Coding style improvements for project_euler problem 45 & 16 (#3087)
* improvements for project euler task 45

* fixed documentation

* update pe_16/sol1.py

* update pe_16/sol2.py

* revert solution changes for sol1

* revert solution changes for sol2

* remove trailing spaces in sol1

* Update sol1.py

Co-authored-by: Dhruv <dhruvmanila@gmail.com>
2020-10-09 12:09:44 +05:30
Juan José Torres
216a194e9a
[Project Euler] Fix code style for problems 15 and 34 (#3076)
* Add type hints and default args to problem 15

* Changes function's name to solution in problem 34

* Update sol1.py

* Update sol1.py

Co-authored-by: Dhruv <dhruvmanila@gmail.com>
2020-10-09 08:46:55 +05:30
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