Commit Graph

3206 Commits

Author SHA1 Message Date
Neha
6497917352
Added Kth largest element algorithm (#10687)
* neha3423

* neha3423

* neha3423

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* neha3423

* neha3423

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* neha323

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* neha3423

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* neha3423

* neha3423

* neha3423

* neha3423

* Added test case for tuple

* Update kth_largest_element.py

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2023-10-26 10:54:30 +02:00
Saurabh Mahapatra
ade2837e41
Update capitalize.py (#10573)
* Update capitalize.py

* Update strings/capitalize.py

---------

Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
2023-10-26 04:25:08 -04:00
Mary-0165
e791a2067b
Capacitor equivalence algorithm (#9814)
* capacitor equivalence algorithm

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Apply suggestions from code review

* Update capacitor_equivalence.py

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
2023-10-26 04:10:13 -04:00
Sanjay
e5a6a97c32
Added Lens formulae to the Physics repository (#10187)
* Added Lens formulae to the Physics repository

* Resolved the commented issues

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update lens_formulae.py

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
2023-10-26 03:58:40 -04:00
Suyash Dongre
dd7d18d49e
Added doctest, docstring and typehint for sigmoid_function & cost_function (#10828)
* Added doctest for sigmoid_function & cost_function

* Update logistic_regression.py

* Update logistic_regression.py

* Minor formatting changes in doctests

* Apply suggestions from code review

* Made requested changes in logistic_regression.py

* Apply suggestions from code review

---------

Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
2023-10-26 03:55:56 -04:00
Ravi Kumar
c71c280726
added runge kutta gills method to maths/ numerical_analysis (#10967)
* added runge kutta gills method

* Apply suggestions from code review

---------

Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
2023-10-26 03:20:28 -04:00
Ed
a8f05fe0a5
Add doctests and type hints (#10974)
* Add doctests and type hints

* Apply suggestions from code review

* Update tarjans_scc.py

* Update tarjans_scc.py

---------

Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
2023-10-26 03:02:35 -04:00
Megan Payne
1a5d5cf93d
Mean absolute error (#10927)
* added mean absolute error to loss_functions.py

* added doctest to mean absolute error to loss_functions.py

* fixed long line in loss_functions.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fixed error in MAE

* Update machine_learning/loss_functions.py

Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
2023-10-26 01:31:47 -04:00
Dale Dai
0e7f8284a3
Add error tests in doctest and fix error message (#10930)
* Add error tests in doctest and fix error message

* Change AssertationError to ValueError

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-10-26 01:27:46 -04:00
Humzafazal72
0ffe506ea7
added mean absolute percentage error (#10464)
* added mean absolute percentage error

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* added mean_absolute_percentage_error

* added mean_absolute_percentage_error

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* added mean_absolute_percentage_error

* added mean_absolute_percentage_error

* added mean absolute percentage error

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* added mean absolute percentage error

* added mean absolute percentage error

* added mean absolute percentage error

* added mean absolute percentage error

* added mean absolute percentage error

* Update machine_learning/loss_functions.py

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
2023-10-25 19:05:35 -04:00
Bisma nadeem
e1e5963812
Code Enhancements in merge_sort.py (#10911)
* Code Enhancements in merge_sort.py 

This enhanced code includes improved variable naming, error handling for user input, and more detailed docstrings. It's now more robust and readable.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-10-25 17:26:54 -04:00
AdityaAtoZ
3d0a409ce1
Improved Equilibrium Index of an Array. (#10899)
* Improved Equilibrium Index of an Array.

This is the modifications made to the original code:

1. Create Doctest Instructions: Python "doctest" can be executed by running the following command: python -m doctest -v equilibrium_index.py.

2. Deleted Argument {size}: Deleted the `size` argument because `len(arr)} allows the array's length to be determined inside the function, simplifying and improving the readability of the function signature.

3. Used {enumerate}: To improve code readability and indicate that we're working with element-index pairs, we iterated through the array using both elements and their indices using the `enumerate` function.

4. Optimized the Loop: To prevent pointless additions, the loop was improved by initializing {left_sum} with the value of the first element (arr[0]). Furthermore, since the beginning and last items (0 and size - 1) cannot be equilibrium indices, there is no need to check them, saving further computations.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-10-25 16:33:35 -04:00
Christian Clauss
c2c6cb0f5c
Add dataclasses to binary_search_tree.py (#10920) 2023-10-25 16:28:23 -04:00
Iyiola Aloko
76acc6de60
Adding doctests to frequency_finder.py (#10341)
* Update frequency_finder.py

* Update frequency_finder.py

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
2023-10-24 21:53:31 +00:00
Bisma nadeem
dab4e64896
Code enhancements in binary_insertion_sort.py (#10918)
* Code enhancements in binary_insertion_sort.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Apply suggestions from code review

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2023-10-24 23:51:04 +02:00
Hardik Pawar
fd227d8026
Add function docstrings, comments and type hints (#10893)
* Add function docstrings, comments and type hints

* Fix type mismatch

* Fix type hint error

* Fix float to int error

* Update ford_fulkerson.py

* Update ford_fulkerson.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update ford_fulkerson.py

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-10-24 23:35:38 +02:00
Dhruv Manilawala
28302db941
Remove myself from CODEOWNERS (#10220) 2023-10-24 17:53:17 +02:00
Hardik Pawar
aeee0f42a5
Add doctests for fractional knapsack (#10891)
* Add doctests for fractional knapsack

* Update greedy_methods/fractional_knapsack.py

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

* Run doctests

* Update greedy_methods/fractional_knapsack.py

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

* Update greedy_methods/fractional_knapsack.py

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
2023-10-24 16:36:24 +02:00
Saptadeep Banerjee
28f4c16132
Tried new TESTS for the binomial_coefficient (#10822)
* Tried new TESTS for the binomial_coefficient

* Fix the tests request

* Update binomial_coefficient.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update binomial_coefficient.py

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-10-24 15:46:00 +02:00
SEIKH NABAB UDDIN
a23dd7ecbe
Change from only weatherstack to both (#10882)
* Update current_weather.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update current_weather.py

* Update current_weather.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update current_weather.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update current_weather.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update current_weather.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update current_weather.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update current_weather.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update current_weather.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update current_weather.py

* Update current_weather.py

* Update current_weather.py

* Update current_weather.py

* import requests

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2023-10-24 15:12:32 +02:00
Christian Clauss
eb17fcf8f5
Use dataclasses in circular_linked_list.py (#10884)
* Use dataclasses in circular_linked_list.py

* updating DIRECTORY.md

---------

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2023-10-24 08:45:36 -04:00
Bhavesh Mathur
17059b7ece
Added doctests , type hints for other/nested_brackets.py (#10872)
* Added doctests , type hints

* Update nested_brackets.py

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
2023-10-24 11:03:22 +02:00
Gourav Raj
481aff7928
Add Mirror a Binary Tree solution (#9534)
* Add `Invert a Binary Tree` solution

* Add type

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Add `doctest`

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Add `test` to `get_tree_inorder`

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Add `test` changes

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix lint errors

* Fix precommit errors

* Update and rename invert_binary_tree.py to mirror_binary_tree.py

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2023-10-24 09:54:38 +02:00
Marek Mazij
6971af2416
feat: RGB to CMYK color converter (#10741)
* feat: code functional, commented, tested

* fix: compering types, exception msg, line length

* fix: type hints
2023-10-23 18:22:09 -04:00
Tianyi Zheng
b98312ca9f
Consolidate Newton-Raphson implementations (#10859)
* updating DIRECTORY.md

* updating DIRECTORY.md

* Consolidate Newton-Raphson duplicates

* Rename consolidated Newton-Raphson file

* updating DIRECTORY.md

* updating DIRECTORY.md

* Fix doctest precision

* Fix doctest precision again

---------

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2023-10-23 16:37:17 -04:00
pre-commit-ci[bot]
e5d6969f38
[pre-commit.ci] pre-commit autoupdate (#10856)
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.0.292 → v0.1.1](https://github.com/astral-sh/ruff-pre-commit/compare/v0.0.292...v0.1.1)
- [github.com/psf/black: 23.9.1 → 23.10.0](https://github.com/psf/black/compare/23.9.1...23.10.0)
- [github.com/pre-commit/mirrors-mypy: v1.6.0 → v1.6.1](https://github.com/pre-commit/mirrors-mypy/compare/v1.6.0...v1.6.1)

* updating DIRECTORY.md

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2023-10-23 22:29:16 +02:00
SEIKH NABAB UDDIN
ffd3a56c35
Updated Selection Sort (#10855)
* Update selection_sort.py

* Update selection_sort.py
2023-10-23 14:12:28 -04:00
Aqib Javid Bhat
30122062b9
Add Floyd's Cycle Detection Algorithm (#10833)
* Add Floyd's Cycle Detection Algorithm

* Add tests for add_node function

* Apply suggestions from code review

* Update floyds_cycle_detection.py

---------

Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
2023-10-23 13:56:43 -04:00
Hardik Pawar
54e2aa67e8
Enhance readability of Minimax (#10838)
* Enhance readability of Minimax

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Reduce line overflow

* Update backtracking/minimax.py

Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>

* Update backtracking/minimax.py

Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>

* Update backtracking/minimax.py

Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>

* Remove line overflow

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
2023-10-23 13:42:02 -04:00
Tauseef Hilal Tantary
4cbefadbd7
[New Algorithm] - Triangular Numbers (#10663)
* Add New Algorithm: Triangular Numbers

* Calculate nth triangular number instead of generating a list

* Handle 0th position and update function name and docstring
2023-10-23 09:51:09 -04:00
Berat Osman Demiralay
d051db1f14
Add Simple Moving Average (SMA) Calculation (#9300)
* Add Simple Moving Average (SMA) Calculation

This commit adds a Python script for calculating the Simple Moving Average (SMA) of a time series data.

The script also includes a doctest that verifies the correctness of the SMA calculations for a sample dataset.

Usage:
- Run the script with your own time series data and specify the window size for SMA calculations.

* Update financial/simple_moving_average.py

Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>

* Update financial/simple_moving_average.py

Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>

* Update financial/simple_moving_average.py

Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update simple_moving_average.py

* Update financial/simple_moving_average.py

* Update simple_moving_average.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-10-23 09:25:07 -04:00
Krishna-singhal
417b7edfc3
code enhancement in sort.double_sort (#10798)
* don't need to return list because list is mutable

* Don't need to return list as list is mutable
* use advantage of python in swapping
* filter blank inputs from input list
* minor changes

* minor mistake

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* more readable

* Update double_sort.py

* last fixes

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Apply suggestions from code review

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2023-10-23 09:51:27 +02:00
Tianyi Zheng
a8b6bda993
Delete arithmetic_analysis/ directory and relocate its contents (#10824)
* Remove eval from arithmetic_analysis/newton_raphson.py

* Relocate contents of arithmetic_analysis/

Delete the arithmetic_analysis/ directory and relocate its files because
the purpose of the directory was always ill-defined. "Arithmetic
analysis" isn't a field of math, and the directory's files contained
algorithms for linear algebra, numerical analysis, and physics.

Relocated the directory's linear algebra algorithms to linear_algebra/,
its numerical analysis algorithms to a new subdirectory called
maths/numerical_analysis/, and its single physics algorithm to physics/.

* updating DIRECTORY.md

---------

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2023-10-23 09:31:30 +02:00
Dale Dai
a9cee1d933
Add perfect cube binary search (#10477)
* Add perfect cube binary search algorithm

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Add support for testing negative perfect cubes

* Add TypeError check for invalid inputs

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-10-23 01:56:59 -04:00
Paarth Goyal
abc390967d
Added the algorithm to compute the terminal velocity of an object fal… (#10237)
* added the algorithm to compute the terminal velocity of an object falling in a fluid

* fixed spelling mistake

* fixed issues in topic description

* imported the value of g from scipy and changed the doctests accordingly

* fixed formatting

* Apply suggestions from code review

---------

Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
2023-10-23 01:43:30 -04:00
Pratik Tripathy
68faebe711
feat: Add mass energy equivalence in physics and doctests (#10202)
* updating DIRECTORY.md

* feat: Add mass energy equivalence in physics

* updating DIRECTORY.md

* updating DIRECTORY.md

* Apply suggestions from code review

* Update physics/mass_energy_equivalence.py

* Update mass_energy_equivalence.py

---------

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
2023-10-23 01:35:10 -04:00
Suyash Dongre
dc4e89805a
Added docstring/documentation for sigmoid_function (#10756)
* Added doctest for sigmoid_function

* Added doctest for sigmoid_function

* Added doctest for sigmoid_function
2023-10-23 01:27:33 -04:00
Ankit Avinash
abd6bca074
Added Binary Focal Cross Entropy (#10674)
* Added Binary Focal Cross Entropy

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fixed Issue

* Fixed Issue

* Added BFCE loss to loss_functions.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update machine_learning/loss_functions.py

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
2023-10-23 01:24:51 -04:00
Anshu Sharma
fdb0635c71
added doctest to playfair_cipher.py (#10823)
* added doctest to playfair_cipher.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Added newline to EOF andremoved trailing whitespace

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Apply suggestions from code review

---------

Co-authored-by: Keyboard-1 <142900182+Keyboard-1@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
2023-10-22 17:39:31 -04:00
Hardik Pawar
a8b94abc8b
Enhance readability of N Queens (#9265)
* Enhance readability of N Queens

* Simplify is_safe code

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Apply suggestions from code review

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
2023-10-22 14:51:56 -04:00
Jeel Gajera
6c8743f1e6
Add: Time Conversion Function (#10749)
* Add: Time Conversion Function

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update conversions/time_conversions.py

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

* fix: required changes

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix: err

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update time_conversions.py

---------

Co-authored-by: Jeel Gajera <jeelgajera00@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2023-10-22 15:51:30 +02:00
Kento
7d0f6e012a
Updated doctests for nor_gate (#10791)
* added other possible cases

* added test for correct output of truth table

* updating DIRECTORY.md

* Update nor_gate.py

---------

Co-authored-by: = <=>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2023-10-22 11:08:08 +02:00
gio-puter
0601b56173
Add tests without modifying code (#10740)
* Contributes to #9943
Added doctest to largest_of_very_large_numbers.py
Added doctest to word_patterns.py
Added doctest to onepad_cipher.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Contributes to #9943
Added doctest to maths/largest_of_very_large_numbers.py
Added doctest to strings/word_patterns.py
Added doctest to ciphers/onepad_cipher.py

* Add tests without modifying code #10740
Added test to maths/largest_of_very_large_numbers
Added test to strings/word_patterns.py
Added test to ciphers/onepad_cipher.py

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-10-22 07:42:26 +02:00
santiditomas
d73a4c2ee0
adding new physics algorithm: center of mass (#10743)
* adding new physics algorithm: center of mass

* Add changes requested by the reviewer

* Add changes requested by the reviewer

* Update center_of_mass.py

* Update center_of_mass.py

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
2023-10-22 01:59:41 +02:00
Precious C. Jacob
c92e86bd79
Add tests to data_structures/linked_list/swap_nodes.py (#10751)
* Added doctests to the swap_nodes file under linkedlist data structure

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Added doctests to the swap_nodes file under linkedlist data structure

* Added doctests to the swap_nodes file under linkedlist data structure

* Added doctests to the swap_nodes file under linkedlist data structure

* Update swap_nodes.py

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2023-10-22 01:33:49 +02:00
Barun Parua
d9562033f6
added a function to calculate perceived frequency by observer using Doppler Effect (#10776)
* avg and mps speed formulae added

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* avg and mps speed formulae added

* fixed_spacing

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* spacing

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* ws

* added amicable numbers

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* added amicable numbers

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* spacing

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* removed

* changed name of file and added code improvements

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* issues fixed due to pi

* requested changes added

* Created doppler_effect_of_sound.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Updated doppler_effect_of_sound.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* added desc names

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fixed spacing

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* renamed doppler_effect_of_sound.py to doppler_frequency.py

* used expection handling rather than print statements

* fixed spacing for ruff

* Update doppler_frequency.py

This is super slick!  Well done.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2023-10-22 00:33:50 +02:00
Saptadeep Banerjee
4707fdb0f2
Add tests for Perfect_Number (#10745)
* Added new tests!

* [ADD]: Inproved Tests

* fixed

* Removed spaces

* Changed the file name

* Added Changes

* changed the code and kept the test cases

* changed the code and kept the test cases

* missed the line

* removed spaces

* Update power_using_recursion.py

* Added new tests in Signum

* Few things added

* Removed few stuff and added few changes

* Fixed few things

* Reverted the function

* Update maths/signum.py

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

* Added few things

* Update maths/signum.py

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

* Added the type hint back

* Update signum.py

* Added NEW tests for Perfect_Number

* Update maths/special_numbers/perfect_number.py

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

* Added the line back

* Update maths/special_numbers/perfect_number.py

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

* Fixed a space

* Updated

* Reverted changes

* Added the old code and FIXED few LINES

* Fixed few things

* Changed Test CASES

* Update perfect_number.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-10-22 00:05:37 +02:00
Kiarash Hajian
b814cf3781
add exponential search algorithm (#10732)
* add exponential_search algorithm

* replace binary_search with binary_search_recursion

* convert left type to int to be useable in binary_search_recursion

* add docs and tests for exponential_search algorithm

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* move exponential_search to binary_search.py to pass github auto build tests

delete exponential_search.py file

* Update searches/binary_search.py

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

* remove additional space  searches/binary_search.py

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

* return single data type in exponential_search searches/binary_search.py

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

* add doctest mod searches/binary_search.py

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

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* use // instread of int() convert  searches/binary_search.py

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

* change test according to new code searches/binary_search.py

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

* fix binary_search_recursion multiple type return error

* add a timeit benchmark for exponential_search

* sort input of binary search to be equal in performance test with exponential_search

* raise value error instead of sorting input in binary and exonential search to fix bugs

* Update binary_search.py

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: user <user@kali.user>
2023-10-21 20:53:34 +02:00
Tianyi Zheng
06edc0eea0
Consolidate binary exponentiation files (#10742)
* Consolidate binary exponentiation files

* updating DIRECTORY.md

* Fix typos in doctests

* Add suggestions from code review

* Fix timeit benchmarks

---------

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2023-10-21 13:27:36 -04:00
Jeel Gajera
47c19d9b2d
Add: FP Growth Algorithm (#10746)
* Add: FP Growth Algorithm

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* changes names

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Revert "changes names"

This reverts commit c0470094d0.

* refactore code

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update frequent_pattern_growth.py

---------

Co-authored-by: Jeel Gajera <jeelgajera00@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2023-10-21 16:51:29 +02:00