* Update cocktail_shaker_sort.py
Added a docstring with clear explanations of the function and its parameters.
Changed variable names i, start, and end for better readability.
Improved comments to describe the purpose of each section of the algorithm.
Adjusted the loop ranges to make the code more concise and readable.
Removed redundant comments and variable assignments.
Provided a clear message when printing the sorted list.
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update cocktail_shaker_sort.py
* typing: ignore[operator]
* Update cocktail_shaker_sort.py
* Update cocktail_shaker_sort.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>
* 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>
* 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>
* 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>
* 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>
* 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>
* 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>
* 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>
* 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>
* 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>
* 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>
* 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>
* 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>
* Add New Algorithm: Triangular Numbers
* Calculate nth triangular number instead of generating a list
* Handle 0th position and update function name and docstring
* 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>
* 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>
* 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>
* 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>
* 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>
* 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>
* 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>
* 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>
* 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>
* 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>
* 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>
* 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>
* 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>