Commit Graph

1880 Commits

Author SHA1 Message Date
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
Jenia Dysin
9d745b6156
Add typehints ciphers and bool alg (#3264)
* updating DIRECTORY.md

* updating DIRECTORY.md

* Fixed accidental commit of file I have't touched

* fixup! Format Python code with psf/black push

* updating DIRECTORY.md

* updating DIRECTORY.md

* Fixed some suggested coding style issues

* Update rsa_key_generator.py

* Update rsa_key_generator.py

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: John Law <johnlaw.po@gmail.com>
2020-10-16 14:11:52 +08:00
Christian Clauss
5b024f4dd5
BROKEN BUILD: Fix a failing precommit test (#3344)
* Fix a failing precommit test

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-16 00:33:25 +02:00
Meysam
cc050dbf5b
test/graphs/prim: writing a test case to verify the correctness of the algorithm (#2454) 2020-10-15 21:10:35 +02:00
Meysam
83b825027e
Graphs/kruskal: adding doctest & type hints (#3101)
* graphs/kruskal: add doctest & type hints

this is a child of a previous PR #2443

its ancestor is #2128

* updating DIRECTORY.md

* graphs/kruskal: fix max-line-length violation

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-15 21:08:52 +02:00
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
Christian Clauss
2e90debab3
Tighten up quicksort() (#3319)
* Tighten up quicksort()

* updating DIRECTORY.md

* str does not support .pop()

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-15 15:07:34 +02:00
Mozartus
f0033f87e0
Create natural_sort.py (#3286)
* add natural_sort.py

* fix doctest

* add 're' to requirements.txt and fix spelling errors

* delete 're' from requirements.txt

* fixing linting errors

* Update sorts/natural_sort.py

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

* Update sorts/natural_sort.py

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

* Update natural_sort.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-10-15 13:45:17 +02:00
Christian Clauss
7c5cc28ba2
Revert recent changes to .pre-commit-config.yaml (#3318)
* Revert recent changes to .pre-commit-config.yaml

We must continue to insist that algorithmic functions can not print() as discussed in CONTRIBUTING.md.

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-15 16:50:43 +05:30
Anshraj Shrivastava
e035c6164f
add binary_tree_traversals.py to data_structures (#3297)
* add binary_tree_traversals.py to data_structures

I have added some interesting binary tree traversing methods.

* Fixed error

* Update data_structures/binary_tree/binary_tree_traversals.py

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

* Update binary_tree_traversals.py

* Update binary_tree_traversals.py

* Update binary_tree_traversals.py

* Update data_structures/binary_tree/binary_tree_traversals.py

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

* Update binary_tree_traversals.py

* Update binary_tree_traversals.py

* Update binary_tree_traversals.py

* Update binary_tree_traversals.py

* Update binary_tree_traversals.py

* Update binary_tree_traversals.py

* Update binary_tree_traversals.py

* Update binary_tree_traversals.py

* Update binary_tree_traversals.py

* Update binary_tree_traversals.py

* Update data_structures/binary_tree/binary_tree_traversals.py

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

* Update binary_tree_traversals.py

* Update binary_tree_traversals.py

* Update data_structures/binary_tree/binary_tree_traversals.py

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

* Update data_structures/binary_tree/binary_tree_traversals.py

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

* Update binary_tree_traversals.py

* Update data_structures/binary_tree/binary_tree_traversals.py

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

* Update binary_tree_traversals.py

* Doctests and type hints

* Add spaces

* Update binary_tree_traversals.py

* black exclude data_structures/binary_tree/binary_tree_traversals.py

* Add spaces again

* Update binary_tree_traversals.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-10-15 13:09:59 +02:00
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
Christian Clauss
aeb6edc792
.pre-commit-config.yaml: Disable trailing-whitespace fixer (#3306)
* .pre-commit-config.yaml: Disable trailing-whitespace fixer

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-15 11:11:22 +02:00
Akash G Krishnan
de2725f4ac
Update mergesort.py (#2563)
* Update mergesort.py

1) Updating the merge sort in python as the previous implementation was modifying the input array
2) divided the division part and conquer part of the merge sort algorithm as 2 functions namely mergeSort and merge.
3) function mergeSort divides the function into halves i.e the purpose of the function will be to divide the array
4) function merge will merge 2 halves into a sorted array
5)Added random test cases using shuffle as suggested by @dhruvmanila
6 The time and space complexity of the previous and my version remains the same. i.e (n log(n) time and n log(n) space
7) changed variables as per the python case as required and suggested by @dhruvmanila
8) Updated function names as suggested by @dhurvmanila

* Update mergesort.py

Added in few more test cases 
added type hints for the functions and parameters as suggested by @dhruvmanila
formatted the code using Auto Pep8

* Update mergesort.py

update and added new testcases

* Update mergesort.py

Added in doc test in merge function

* Update mergesort.py

fixing pre-commit fails

* Update mergesort.py

Co-authored-by: Dhruv <dhruvmanila@gmail.com>
2020-10-15 14:00:12 +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
Mayur Pardeshi
ed30749943
Added swap case program and removed unexpected expression part (#3212)
* Removed an extra '=' which was creating an error while running a program.

* Removed the unexpected expression part.

* Added program for swap cases in string folder

* removed if condition and exchange word with char

* added '=' sign which I removed before because of unknowing error from pycharm

* added space in test

* removed costraint from problem statement

* Update cocktail_shaker_sort.py

* Update naive_string_search.py

* Update swap_case.py

* psf/black " not '

* added new line at the end of the file

* Fix flake8 issues

* added new line at the end of the file

* added True and fixed comment

* python file end with \n

* Update swap_case.py

* Update strings/swap_case.py

* Update strings/swap_case.py

* Apply suggestions from code review

* Update strings/swap_case.py

* Update swap_case.py

* Update swap_case.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-10-15 00:19:00 +02:00
Christian Clauss
fda57d6924
codespell.yml: Remove unused install of flake8 (#3283)
* codespell.yml: Remove unused install of flake8

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-14 17:02:47 +05:30
Phil Bazun
e3c07f987f
Add skew heap data structure. (#3238)
* Add skew heap data structure.

* fixup! Add skew heap data structure.

* fixup! Add skew heap data structure.

* fixup! Add skew heap data structure.

* Add tests.

* Add __iter__ method.

* fixup! Add __iter__ method.
2020-10-14 12:35:53 +02:00
Mikail Farid
5fcd250c99
Added decimal_to_binary_recursion.py (#3266)
* Added decimal_to_binary_recursion.py

* Added decimal_to_binary_recursion.py

* Made changes to docstring

* Use divmod()

* binary_recursive(div) + str(mod)

* Be kind with user input if possible

* Update decimal_to_binary_recursion.py

* ValueError: invalid literal for int() with base 10: 'number'

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-10-14 12:27:08 +02:00
NAVEEN S R
75a9b460ad
added script to perform quantum entanglement (#3270)
* added code to perform quantum entanglement

* Update quantum_entanglement.py
2020-10-14 12:25:20 +02:00
Susmith98
dc069580b9
Added binary tree mirror algorithm (#3159)
* Added binary tree mirror algorithm

* Minor changes

* Resolved comments

* Minor Changes

* resolved comments and updated doctests

* updated doctests

* updating DIRECTORY.md

Co-authored-by: svedire <VedireSusmith_Reddy@intuit.com>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-14 12:21:15 +02:00
Phil Bazun
f0aa63f0f9
Add randomized heap. (#3241) 2020-10-14 12:17:02 +02:00
NAVEEN S R
35eefac359
fixed error (#3281)
this will fix code from randomly throwing `SystemExit: The affine cipher becomes weak when key B is set to 0. Choose different key` exception.
2020-10-14 11:53:37 +02:00
mateuszz0000
f164e11db4
Update CODEOWNERS (#3280)
* Update CODEOWNERS

* Reduce @cclauss notifications during Hacktoberfest

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-10-14 11:05:17 +02:00
Dhruv
23ab159f30
Fix errors in Quantum algorithm (#3273)
* Fix pre-commit errors in Quantum algorithm

* updating DIRECTORY.md

* Fix doctest

* Update not_gate.py

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-14 07:58:52 +02:00
Dhruv
34d63d5155
Fix Travis CI slow build on Project Euler Solution job (#3262)
* Fix Travis CI long run for validate_solutions

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-13 22:43:40 +05:30
Abhishek Jaisingh
ca2d269ed2
Add Qiskit Quantum NOT Gate Example Code (#3255)
* Add Qiskit Quantum NOT Gate Example Code

* Address Review Comments

Signed-off-by: Abhishek Jaisingh <abhi2254015@gmail.com>
2020-10-13 18:34:24 +02:00
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
Abhishek Jaisingh
6e01004535
Add First Quantum Qiskit Code Tutorial (#3173)
* Add First Quantum Qiskit Code Tutorial

* Add Qiskit Requirement

* Address Review Comments

* fixup! Format Python code with psf/black push

* Update q1.py

* updating DIRECTORY.md

* Update and rename q1.py to single_qubit_measure.py

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2020-10-12 21:41:05 +02:00
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
Christian Clauss
695217e964
Update CODEOWNERS (#3235) 2020-10-12 20:57:55 +05:30
Kushagra Bansal
08c26e667b
Update CODEOWNERS to add my preferences (#3233)
* Update CODEOWNERS

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-12 16:23:21 +02:00
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
forgithub0001
7a671483b6
Update README.md (#3221) 2020-10-12 14:10:42 +05:30
forgithub0001
e551004551
Update CONTRIBUTING.md (#3223) 2020-10-12 14:08:50 +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
PotatoK123
3859c65995
Added rail fence cipher (#3188)
* Added rail fence cipher

* Update rail_fence_cipher.py

* Update rail_fence_cipher.py
2020-10-12 10:37:45 +05:30
Christian Clauss
f7e7ad2ef6
CONTRIBUTING.md Jupyter files belong in the Jupyter repo. (#3211)
* CONTRIBUTING.md Jupyter files belong in the Jupyter repo.

* updating DIRECTORY.md

* Update CONTRIBUTING.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: John Law <johnlaw.po@gmail.com>
2020-10-12 08:17:26 +08:00
eba
3aef85bcec
Fix English grammar in computer vision (#3210) 2020-10-12 08:17:01 +08:00
Jr Miranda
c425010c44
Fetch CO2 emission information (#3182)
* Fetch CO2 emission information

* fix blank lines

* fix blank lines

* Add type hints for function return values

* Update co2_emission.py

* Update co2_emission.py

* Update co2_emission.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-10-12 01:31:56 +02:00
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
Christian Clauss
731190842a
CODEOWNERS: Proper spelling of my userid (#3185)
* CODEOWNERS: Proper spelling of my userid

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-11 15:23:30 +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