Commit Graph

2192 Commits

Author SHA1 Message Date
Username
3f2b238c34 Fixed type annotations 2021-09-14 15:30:42 -04:00
Username
dcacc95b9d Added float tests 2021-09-07 15:18:18 -04:00
Username
4e2fcaf6fb Fixes #4710 added exceptions and tests 2021-09-07 15:15:08 -04:00
Aviv Faraj
07646ac92b
Update horizontal_projectile_motion.py 2021-09-07 14:41:47 -04:00
Aviv Faraj
ee49ce7022
Merge branch 'TheAlgorithms:master' into master 2021-09-07 09:41:21 -04:00
Aviv Faraj
894fa7f009
Update horizontal_projectile_motion.py 2021-09-07 09:37:33 -04:00
Aviv Faraj
c0e5071e79
Modified prints to f-string 2021-09-07 09:35:30 -04:00
Aviv Faraj
132e4952ee
Fixed angle condition 2021-09-07 09:32:55 -04:00
Aviv Faraj
db7db3b370
reversed tests 2021-09-07 09:31:36 -04: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
Aviv Faraj
5d5831bdd0
Physics new code (#4709)
* added gamma_function

* Add files via upload

* Resolved issue with str.format

And also changed output to math notation

* Update gamma_function.py

* Rename physics/gamma_function.py to maths/gamma_recursive.py

* Fixes: #4709 Fixed issues for pre-commit test

* Fixes: #4709 solved issues with doctests

And comments

* Fixes: #4709 Added failed tests to doctest

* Align with Python's Standard Library math.gamma()

Replicate the exceptions of https://docs.python.org/3/library/math.html#math.gamma

* Update gamma_recursive.py

* Update gamma_recursive.py

* Update gamma_recursive.py

* Update gamma_recursive.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2021-09-06 23:57:18 +02:00
Aviv Faraj
cea2deb0c8
removed pi 2021-09-06 13:59:46 -04:00
Aviv Faraj
2841c11da1
Deleted duplicate file 2021-09-06 13:58:46 -04:00
Username
7bd84b4eee Updated gamma 2021-09-06 13:55:20 -04:00
Username
1d4fc814fa Updated file 2021-09-06 13:16:58 -04:00
Aviv Faraj
974e0a6e95
Updated file according to pre-commit test 2021-09-06 13:08:33 -04:00
avivfaraj
bc31e3fa71
imported radians from math 2021-09-05 12:56:31 -04:00
avivfaraj
552546f2c1
File exists in another pull request 2021-09-04 12:55:13 -04:00
avivfaraj
6550183d99
Fixes: #4710 provided return type 2021-09-04 12:53:35 -04:00
avivfaraj
ff2a162bdd
Add files via upload 2021-09-04 12:41:26 -04:00
avivfaraj
4951686999
Changed print to f-string
Also printed out results in a math notation
2021-09-04 10:19:15 -04:00
avivfaraj
a56525855c
Add files via upload 2021-09-03 19:47:55 -04:00
imp
c1b15a86ba
[mypy] Fix type annotations for dynamic programming (#4687)
* Fix mypy error for knapsack.py

* Fix mypy error for longest_increasing_subsequence

* Fix mypy error for fractional_knapsack_2.py
2021-09-03 11:49:23 +02:00
Kiran Hipparagi
757d4fb84f
Added Dutch National Flag algorithm #4636 (#4639)
* Added Dutch national flag sort Algorithm

* Changed file name to dnf_sort.py

* Added descriptive name and type hint 

Added descriptive name and type hint  for parameter with doctest for the function dnf_sort.

* Added test cases

* Added doctest cases

* Update sorts/dnf_sort.py

* Added doctest for dutch_national_flag_sort sorts/dnf_sort.py

* Update sorts/dnf_sort.py

* Added doctest for the function
dutch_national_flag_sort

* update file as per black code formatter

* Update dnf_sort.py

* Update and rename dnf_sort.py to dutch_national_flag_sort.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2021-08-31 22:06:49 +02:00
Christian Clauss
ef9827166e
Approve functions used as default arguments (#4699)
* Approve functions used as default argumenets

* The default value for **seed** is the result of a function call

The default value for **seed** is the result of a function call which is not normally recommended and causes flake8-bugbear to raise a B008 error. However, in this case, it is accptable because `LinearCongruentialGenerator.__init__()` will only be called once per instance and it ensures that each instance will generate a unique sequence of numbers.

* The default value for **backend** is the result of a function call

The default value for **backend** is the result of a function call which is not normally recommended and causes flake8-bugbear to raise a B008 error. However, in this case, it is accptable because `Aer.get_backend()` is called when the function is definition and that same backend is then reused for function calls.

* Update linear_congruential_generator.py

* Update ripple_adder_classic.py

* Update ripple_adder_classic.py

* Update ripple_adder_classic.py

* Update ripple_adder_classic.py

* Update ripple_adder_classic.py
2021-08-31 07:56:19 +02:00
Christian Clauss
097f830238
Avoid mutable default arguments (#4691) 2021-08-31 06:56:15 +02:00
Aswin Murali
3acca3d1d1
Fix type annotations for integer_partition.py #4052 (#4689) 2021-08-30 10:06:59 +02:00
arfy slowy
8e5c3536c7
[fixed] unused variable, standalone running, import doctest module (#4673)
* [fixed] unused variable, standalone running, import doctest module

information [standalone running](https://www.geeksforgeeks.org/what-does-the-if-__name__-__main__-do/)

Signed-off-by: slowy07 <slowy.arfy@gmail.com>

* Update other/fischer_yates_shuffle.py

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

* [fixed] change to tuple and fixing callfunction

Signed-off-by: slowy07 <slowy.arfy@gmail.com>

* Update matrix/spiral_print.py

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

* Update matrix/spiral_print.py

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

* fixing

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

* [fixed] sprial matrix

Signed-off-by: slowy07 <slowy.arfy@gmail.com>

* Update spiral_print.py

* Update spiral_print.py

* Update spiral_print.py

* Update spiral_print.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2021-08-28 20:07:10 +02:00
Christian Clauss
46e56fa6f2
luhn.py: Favor list comprehensions over maps (#4663)
* luhn.py: Favor list comprehensions over maps

As discussed in CONTRIBUTING.md.

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-08-27 11:45:14 +02:00
imp
5e7eed610c
[mypy] Fix type annotations for strings (#4641)
* Fix mypy error for min_cost_string_conversion.py

* Fix mypy error for manacher.py

* Fix mypy error for aho_corasick.py
2021-08-25 13:35:36 +02:00
Christian Clauss
78a5d3a558
boruvka.py: A few simplifications and f-strings (#4660)
* boruvka.py: A few simplifications and f-strings

Python f-strings simplify the code and [should speed up execution](https://www.scivision.dev/python-f-string-speed). 

@srkchowdary2000 Your review, please.

* updating DIRECTORY.md

* fixup! Streamline the test

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-08-24 15:27:31 +02:00
Shiva Rama Krishna
4ed7c7f09c
Added Borůvka's algorithm. (#4645)
* Added Borůvka's algorithm.

* Added Borůvka's algorithm, a graph algorithm that finds the minimum spanning tree.

* Added Borůvka's algorithm, a graph algorithm that finds the minimum spanning tree.

* Added Borůvka's algorithm, a graph algorithm that finds the minimum spanning tree.

* Added Borůvka's algorithm, a graph algorithm that finds the minimum spanning tree.

* Added Borůvka's algorithm, a graph algorithm that finds the minimum spanning tree. Solved Test Cases Errors.

* Added Borůvka's algorithm, a graph algorithm that finds the minimum spanning tree. Solved Test Cases Errors.

* Added Borůvka's algorithm, a graph algorithm that finds the minimum spanning tree. Solved Test Cases Errors.

* Added Borůvka's algorithm, a graph algorithm that finds the minimum spanning tree. Solved Test Cases Errors.

* Added Borůvka's algorithm, a graph algorithm that finds the minimum spanning tree. Solved Test Cases Errors.

* Added Borůvka's algorithm, a graph algorithm that finds the minimum spanning tree. Solved Test Cases Errors.

* Added Borůvka's algorithm, a graph algorithm that finds the minimum spanning tree. Solved Test Cases Errors.Removed WhiteSpaces.

* Added Borůvka's algorithm, a graph algorithm that finds the minimum spanning tree. Code Changes.

* Added Borůvka's algorithm, a graph algorithm that finds the minimum spanning tree. Code Changes.
2021-08-23 12:35:20 +02:00
imp
20a4fdf384
[mypy] Fix type annotations for strings (#4637)
* Fix mypy error for can_string_be_rearranged_as_pal

* Fix mypy error for levenshtein_distance.py

* Fix mypy error for word_patterns.py

* Fix mypy error for word_occurrence.py
2021-08-19 14:08:20 +02:00
SURYAPRATAP SINGH SURYAVANSHI
9cb5760e89
add date_to_weekday finder method (#4599)
* add date_to_weekday finder method

* reformat date_to_weekday method

* remove time

* remove hardcode weekdays list

* fix return type error

* fixing fail issue

* Finding the test failing issue

* after testing the pre-commit in local environment
2021-08-18 14:05:41 +02:00
imp
af0810fca1
[mypy] Fix type annotations for maths (#4617)
* Fix mypy errors for armstrong_numbers.py

* Fix mypy errors for harmonic_series.py

* Fix mypy errors for average_median.py
2021-08-18 12:45:07 +02:00
imp
4545270ace
[mypy] Fix type annotations for graphs (#4622)
* Fix mypy error for frequent_pattern_graph_miner.py

* Fix mypy error for markov_chain.py
2021-08-18 12:44:26 +02:00
imp
d009cea391
Fix mypy error at maths (#4613)
* Fix mypy errors for maths/greedy_coin_change.py

* Fix mypy errors for maths/two_sum.py

* Fix mypy errors for maths/triplet_sum.py

* Fix the format of maths/greedy_coin_change.py

* Fix the format of maths/greedy_coin_change.py

* Fix format with pre-commit
2021-08-15 21:15:53 +02:00
Bonnie
032999f36e
Create exchange_sort.py (#4600)
* Create exchange_sort.py

added exchange sort

* Fixed doctest in exchange_sort.py

* Fixed formatting error and added new length variable

added empty line at end of exchange_sort.py and turned len(numbers) into a variable

* Fixed formatting errors with black

added empty line
2021-08-15 07:43:05 +02:00
Shubham Ganar
3c225247b8
[mypy] Fix type annotations for strings/naive_string_search.py (#4611) 2021-08-13 09:10:52 +02:00
Hasanul Islam
cd987372e4
Fix multi heuristic astar algo (#4612) 2021-08-13 09:10:24 +02:00
Hasanul Islam
d668c172b0
Refactor graph_initialization at basic_graph.py (#4601) 2021-08-11 22:48:53 +02:00
Shubham Ganar
63ac09eeae
Created check_valid_ip_address.py (#4602)
* Created check_valid_ip_address.py

* fixed typos error

Co-authored-by: root <root@localhost.localdomain>
2021-08-08 20:21:26 +02:00
SURYAPRATAP SINGH SURYAVANSHI
f432bc76a6
add alternative_string_arrange method (#4595)
* add alternative_string_arrange method

* fix issue

* fix one more issue

* changed the variable name li to output_list
2021-08-06 12:15:42 +02:00
jonabtc
5957eabd3e
Adding the double factorial algorithm (#4550) 2021-08-03 08:03:22 +02:00
Hasanul Islam
da71184b04
Fix mypy errors at mst_kruskal (#4581) 2021-08-02 14:40:48 +02:00
Hasanul Islam
a5bcf0f674
Fix mypy errors at even_tree algo (#4579) 2021-07-29 15:14:35 +02:00
Milton Chandro Bhowmick
40d85d5443
Modified the a_star [dot] py for making readable (#4576) 2021-07-28 12:50:21 +02:00
Hasanul Islam
a4b7d12262
Fix mypy errors at greedy best first algo (#4575) 2021-07-27 13:21:00 +02:00
Hasanul Islam
c5003a2c46
Fix mypy errors at bfs_shortest_path algo (#4572) 2021-07-27 10:09:17 +02:00
arfy slowy
6732fa0131
[fixed] module 'numpy' is imported with both 'import' and 'import from' (#4544)
* [fixed] module 'numy' is imported with both 'import' and 'import from'

* remove commented
2021-07-26 14:52:52 +02:00