Commit Graph

2193 Commits

Author SHA1 Message Date
Lewis Tian
77b243e62b
bugfix: Add empty list detection for find_max/min (#4881)
* bugfix: Add empty list detection for find_max/min

* fix shebangs check
2021-10-07 23:20:32 +08:00
Parth Satodiya
d324f91fe7
Fix mypy errors for data_structures->linked_list directory files (#4927) 2021-10-07 23:18:23 +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
Lewis Tian
a4d68d69f1
bugfix: Add abs_max.py & abs_min.py empty list detection (#4844)
* bugfix: Add abs_max.py & abs_min.py empty list detection

* fix shebangs check
2021-10-06 22:06:49 +08:00
Sarvesh Kumar Dwivedi
90db98304e
Fix word typos in comments (#4928)
* fixed: spelling

nonegative -> non-negative

* fixed: spelling

transpostiion -> transposition

* fixed: spelling

topolical -> topological

* fixed: spelling

sufix -> suffix
2021-10-04 12:07:58 +08:00
Nolan Emirot
d530d2bcf4
fix: comment in patience sort (#4972) 2021-10-04 11:33:42 +08:00
DukicDev
c873fa0b1b
Correct grammar of comment in backtracking/hamiltonian_cycle.py (#4868) 2021-10-02 15:51:53 +02:00
DukicDev
31b34af9fa
Correct grammar in backtracking/n_queens_math.py (#4869) 2021-10-02 15:37:28 +02:00
DukicDev
6341f351aa
Fix comments in backtracking/coloring.py (#4857) 2021-10-01 23:48:47 +02:00
ss1208
d1e70cfa3a
docs: renovate README (#4620)
Conjunctive adverbs should be followed by a comma.

For more details, kindly refer:
https://www.aje.com/arc/editing-tip-commas-conjunctive-adverbs/

Separate out the labels into two rows

Co-authored-by: John Law <johnlaw.po@gmail.com>
Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
2021-09-29 23:34:35 +05:30
Arghya Sarkar (ASRA)
b9f18152b7
Create check_polygon.py (#4605)
* Create check_polygon.py

* Update check_polygon.py

* Update maths/check_polygon.py

* Update check_polygon.py

* Update check_polygon.py

Co-authored-by: John Law <johnlaw.po@gmail.com>
2021-09-30 00:49:42 +08:00
Alexandre De Zotti
02bc4bf417
Add Julia sets to fractals (#4382)
* Added Julia sets drawing

* Forgot the .py extension

* Update julia_sets.py

Added online sources for comparison.
Added more examples of fractal Julia sets.
Added all type hints.
Only show one picture
Silented RuntuleWarning's (there's no way of avoiding them and they're not an issue per se)

* Added doctest example for "show_results"

* Filtering Nan's and infinites

* added 1 missing type hint

* in iterate_function, convert to dtype=complex64

* RuntimeWarning (fine) filtering

* Type hint, test for ignore_warnings function, typo in header

* Update julia_sets.py

Type of expected output value for iterate function int array -> complex array (throws an error on test)

* Update julia_sets.py

- More accurate type for tests cases in eval_quadratic_polynomial and iterate_function
- added more characters for variables c & z in eval_quadratic_polynomial and eval_exponential to silent bot warnings

* Function def formatting

Blocked by black

* Update julia_sets.py

* Update fractals/julia_sets.py

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

* Update fractals/julia_sets.py

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

* Update fractals/julia_sets.py

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

* Update fractals/julia_sets.py

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

* Update fractals/julia_sets.py

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

* Update fractals/julia_sets.py

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

* Update fractals/julia_sets.py

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

* added more doctests for eval_exponential

* Update fractals/julia_sets.py

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

Co-authored-by: John Law <johnlaw.po@gmail.com>
2021-09-29 13:42:11 +08:00
Jogendra Singh
5d02103b27
Fixed #4764 (#4779)
* Fixed #4764

* Fixes #4764
2021-09-24 12:54:38 +02:00
Maxim Smolskiy
66a528b171
Improve Project Euler problem 014 solution 2 (#4752) 2021-09-24 02:55:18 +08:00
Christian Clauss
15d1cfabb1
from __future__ import annotations (#4763)
* from __future__ import annotations

* updating DIRECTORY.md

* from __future__ import annotations

* from __future__ import annotations

* Update xor_cipher.py

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-09-22 23:11:51 +02:00
Christian Clauss
dc07a85076
Update and rename check_valid_ip_address.py to is_ip_v4_address_valid.py (#4665)
* Update and rename check_valid_ip_address.py to is_ip_v4_address_valid.py

New test cases that the algorithm must detect:
* [ ] an octet much bigger than 255
* [ ] an octet is negative
* [ ] number of octets is less than 4
* [ ] number of octets is greater than 4
* [ ] an octet is a letter

* updating DIRECTORY.md

* Add two more tests to is_ip_v4_address_valid.py

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: John Law <johnlaw.po@gmail.com>
2021-09-23 02:03:11 +08:00
Christian Clauss
abc725f12d
mypy --install-types --non-interactive . (#4530)
* mypy --install-types --non-interactive .

@dhruvmanila Is this useful/needed given that we do not pin our dependencies?

https://mypy-lang.blogspot.com/2021/06/mypy-0910-released.html

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-09-23 01:37: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
jonabtc
4761fef1a5
Double factorial iterative (#4760)
* Adding the double factorial algorithm

* Adding the double factorial algorithm

Co-authored-by: Jonathan Ocles <jocles@chiang.ec>
2021-09-19 03:22:47 +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
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
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