* Added average absolute deviation
* Formats program with black
* reruns updated pre commit
* Update average_absolute_deviation.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Add points are collinear in 3d algorithm to /maths
* Apply suggestions from code review in points_are_collinear_3d.py
Thanks to cclauss.
Co-authored-by: Christian Clauss <cclauss@me.com>
* Rename some variables to be more self-documenting.
* Update points_are_collinear_3d.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* The black formatter is no longer beta
* pre-commit autoupdate
* pre-commit autoupdate
* Remove project_euler/problem_145 which is killing our CI tests
* updating DIRECTORY.md
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
* Rewrite parts of Vector and Matrix methods
* Refactor determinant method and add unit tests
Refactor determinant method to create separate minor and cofactor
methods.
Add respective unit tests for new methods.
Rename methods using snake case to follow Python naming conventions.
* Reorganize Vector and Matrix methods
* Update linear_algebra/README.md
Co-authored-by: John Law <johnlaw.po@gmail.com>
* Fix punctuation and wording
* Apply suggestions from code review
Co-authored-by: John Law <johnlaw.po@gmail.com>
* Deduplicate euclidean length method for Vector
* Add more unit tests for Euclidean length method
* Fix bug in unit test for euclidean_length
* Remove old comments for magnitude method
* Rewrite maths/fibonacci.py
* Rewrite timer and add unit tests
* Fix typos in fib_binet unit tests
* Fix typos in fib_binet unit tests
* Clean main method
Co-authored-by: John Law <johnlaw.po@gmail.com>
* Rewrite parts of Vector and Matrix methods
* Refactor determinant method and add unit tests
Refactor determinant method to create separate minor and cofactor
methods.
Add respective unit tests for new methods.
Rename methods using snake case to follow Python naming conventions.
* Reorganize Vector and Matrix methods
* Update linear_algebra/README.md
Co-authored-by: John Law <johnlaw.po@gmail.com>
* Fix punctuation and wording
* Apply suggestions from code review
Co-authored-by: John Law <johnlaw.po@gmail.com>
* Deduplicate euclidean length method for Vector
* Add more unit tests for Euclidean length method
* Fix bug in unit test for euclidean_length
* Remove old comments for magnitude method
* Rewrite maths/fibonacci.py
* Rewrite timer and add unit tests
* Fix typos in fib_binet unit tests
* Fix typos in fib_binet unit tests
* Clean main method
* Merge fibonacci.py and fibonacci_sequence_recursion.py
* Fix fib_binet unit test
Co-authored-by: John Law <johnlaw.po@gmail.com>
* Hexagonal number sequence
A hexagonal number sequence is a sequence of figurate numbers where the nth hexagonal number hₙ is the number of distinct dots in a pattern of dots consisting of the outlines of regular hexagons with sides up to n dots, when the hexagons are overlaid so that they share one vertex.
This program returns the hexagonal number sequence of n length.
* Update hexagonalnumbers.py
* Update hexagonalnumbers.py
* Update hexagonalnumbers.py
* Update hexagonalnumbers.py
* Update and rename hexagonalnumbers.py to hexagonal_numbers.py
* Length must be a positive integer
Co-authored-by: Christian Clauss <cclauss@me.com>
* [mypy] Fix type annotation in euler_method.py
In line with issue #4052.
* updating DIRECTORY.md
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
* Update annotations to Python 3.10 #4052
* Add floats doctest
* Copy list to avoid changing input unpredictably
* Refactor code to make it readable
* updating DIRECTORY.md
* Improve raised ValueErrors and add doctest
* Split doctest in multiples lines
* Change ValueError to Monogons and Digons are not poly
* Correct doctest refering number of sides
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
* added harmonic mean
* Update maths/series/harmonic_mean.py
Updated the write-up of reference given in the code.
Co-authored-by: John Law <johnlaw.po@gmail.com>
* changes in arithmetic and geometric mean code
* mean and series added in a single file
Co-authored-by: John Law <johnlaw.po@gmail.com>
* Add Proth number to maths
* Add test for 0 and more informative output
* Fixing test failure issue - unused variable
* Update proth_number.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Magnitude and Angle
Core function to find Magnitude and Angle of two Given Vector
* Magnitude and Angle with Doctest
added Doctest to the functions
* Update linear_algebra/src/lib.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update linear_algebra/src/lib.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Changes done
and Magnitude and Angle Issues
* black
* Modified Euler's Method
Adding Modified Euler's method, which was the further change to a Euler method and known for better accuracy to the given value
* Modified Euler's Method (changed the typing of function)
Modified function is used for better accuracy
* Link added
Added link to an explanation as per Contributions Guidelines
* Resolving Pre-Commit error
* Pre-Commit Error Resolved
* Pre-Commit Error import statement Change
* Removed Import Math
* import math built issue
* adding space pre-commit error
* statement sorter for doc
Co-authored-by: Christian Clauss <cclauss@me.com>
* 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>
* 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>
* 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
* Average mean refactor
Added doctests and type hints to average_mean
* Wiki link added
* Empty list check added
Empty list check added
Type hint changed to typing.List
A serious bug was addressed with this pull request. The mode function previously
didn't return the mode of the input list. Instead, it always returned the first value.
Due to lacking tests, the bug was never caught. This pull request also adds new
functionality to the function, allowing support for more than one mode.
See #4464 for details.
* * Mistake in average_mode.py fixed. The previous solution was to returnthe
value on the first loop iteration, which is not correct, more than that it
used to delete repeating values, so result's array and check array lost
relation between each other
* Type hint added
* redundant check_list deleted
Co-authored-by: Maxim R. <49735721+mrmaxguns@users.noreply.github.com>
* Suggestions resolved
* output typing changed to Any
* test cases added
* Black done
File formatted
* Unused statistics import
statistics only used in doctest, now they are imported in doctest
* Several modes support added
Several modes support added
* Comment fix
* Update maths/average_mode.py
Co-authored-by: Maxim R. <49735721+mrmaxguns@users.noreply.github.com>
* Suggestions added
Co-authored-by: Maxim R. <49735721+mrmaxguns@users.noreply.github.com>
This is a documentation fix. This fix patches a mistake in the description of the Armstrong number.
* * Doc fix
* Armstrong number is not the sum of cube's of number digits, but
the sum of number's digits each raised to the power of the number of digits
* Update armstrong_numbers.py
Line shorten
* Hacktoberfest: Add greedy_coin_change.py file
added the file in greedy_methods folder to implement the same method
Altered the code according to the changes that were requested.
* Added doctests.
doctests added to the function find_minimum_change.
* Added Greedy change file in Maths folder.
* updating DIRECTORY.md
* Deleted Greedy Method Folder
* updating DIRECTORY.md
* Update greedy_coin_change.py
* fix: black formatting issues
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
* Update area.py
Modified area of triangle function. Added a new algorithm to calculate area when 3 sides are known
* Add files via upload
* Update area.py
* Update area.py
* Update area.py
* Update area.py
* Remove unnecessary whitespace
Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
* add type hints to math/gcd
* add doctest
* math/gcd - run black formatter
* math/gcd: remove manual doctest
* add correction to gcd of negative numbers
* add more doctest in iterative gcd
* Made improvements to combinations.py
* Update maths/combinations.py
Co-authored-by: Du Yuanchao <shellhub.me@gmail.com>
* Function now raises an error when given invalid input
* Update maths/combinations.py
Co-authored-by: Du Yuanchao <shellhub.me@gmail.com>
* Add GitHub action file for pre-commit
* Fix errors exposed by pre-commit hook:
- Remove executable bit from files without shebang. I checked those
file and it was not needed.
- Fix with black
* Apply suggestions from code review
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
* Fix all errors mentioned in pre-commit run:
- Fix end of file
- Remove trailing whitespace
- Fix files with black
- Fix imports with isort
* Fix errors
* fix assignment of a variable to itself
* Fix unnecessary 'else' clause in loop
* formatting and redundant reasignment fix
* mark unreachable code with a TODO comment
* fix variable defined multiple times
* fix static method without static decorator
* revert unintended autoformatting
Co-authored-by: Christian Clauss <cclauss@me.com>
* revert autoformatting issue
* applied black autoformatting
Co-authored-by: Christian Clauss <cclauss@me.com>
* * support negative number
* add different version
* fixup! Format Python code with psf/black push
* sum(int(c) for c in str(abs(n)))
* updating DIRECTORY.md
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
* More efficient least common multiple.
* lowest -> least
* integer division
* Update least_common_multiple.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Correcting the Gaussian Formula
I have added the parenthesis around the 2*sigma^2 term.
* Update gaussian.py
* Update gaussian.py
* Update gaussian.py
* Update gaussian.py
* Update gaussian.py
* Update gaussian.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Added Python Program to Check Perfet Number
* CodeSpell Error Fix - 1
* Build Error Fix - 1
* Made suggested changes
* Use generator expression
* Added Python Program to Check Krishnamurthy Number or not
* Added Python Program to Check Krishnamurthy Number
* Added Python Program to Check Krishnamurthy Number or not
* Build Error Fix - 1
* Build Error Fix - 2
* Fix Brackets positions
* Fix Character Exceeding Error
* Made Review Changes
* Build Error Fix - 3
* Build Error Fix - 4
* Update krishnamurthy_number.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* add surface area class
* add new line to end of file
* move surface area class into area class
* add missing import
* added pi import
* fix typo
* added blank line
* fixed more import issues
* comment fix
* comment fixes
* created perfect_cube.py
To find whether a number is a perfect cube or not.
* Update perfect_cube.py
* Update perfect_cube.py
* Update perfect_cube.py
* Added Lstm example for stock predection
* Changes after review
* changes after build failed
* Add Kiera’s to requirements.txt
* requirements.txt: Add keras and tensorflow
* psf/black
* haris corner detection
* fixup! Format Python code with psf/black push
* changes after review
* changes after review
* fixup! Format Python code with psf/black push
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
* create sum_of_digits.py
create sum_of_digits.py to find the sum of digits of a number
digit_sum(12345) ---> 15
digit_sum(12345) ---> 10
* Update sum_of_digits.py
* Update maths/sum_of_digits.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update maths/sum_of_digits.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update sum_of_digits.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Create number_of_digits.py
A python program to find the number of digits in a number.
* Update number_of_digits.py
* Update number_of_digits.py
* Add #1976 to get Travis CI to pass
#1976
* Add type hints as discussed in CONTRIBUTING.md
Co-authored-by: Christian Clauss <cclauss@me.com>
* Tighten up psf/black and flake8
* Fix some tests
* Fix some E741
* Fix some E741
* updating DIRECTORY.md
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
* Precision must be a nonnegative integer
* fixup! Format Python code with psf/black push
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
* consists of area of various geometrical shapes
In this program it consists of various area calculation of different geometrical shapes such as (square,rectangle) and many other shapes.
* print(f'Rectangle: {area_rectangle(10, 20)=}')
* Update area.py
* Areas of various geometric shapes:
Co-authored-by: Christian Clauss <cclauss@me.com>
* Added file aliquot_sum.py containing a function to find theo
* Added parameter type info to aliquot_sum.py
* Update maths/aliquot_sum.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update maths/aliquot_sum.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Updated code to raise ValueErrors if input is bad
* Fixed logical operators
* Removed unnecessary import
* Updated aliquot_sum.py
* fixed formatting
* fixed documentation
Co-authored-by: Christian Clauss <cclauss@me.com>
* improved prime number generator to check only up to sqrt(n) instead of n
* added old version as slow_primes() and named new, faster version primes()
* fixed docstring in slow_primes
* Add a timeit benchmark
* Update prime_numbers.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Fix astar
Single character variable names are old school.
* fixup! Format Python code with psf/black push
* Tuple
* updating DIRECTORY.md
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
* Deal with maps
Try with the search term "pizza" to see why this was done in #1932
* fixup! Format Python code with psf/black push
* Update armstrong_numbers.py
* updating DIRECTORY.md
* Update crawl_google_results.py
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
* Rename math/add.py to maths/add.py
* fixup! Format Python code with psf/black push
* Fix sum to add
* updating DIRECTORY.md
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: John Law <johnlaw.po@gmail.com>
* Add Monte Carlo estimation of PI
* Add type annotations for Monte Carlo estimation of PI
* Compare the PI estimate to PI from the math lib
* accuracy -> error
* Update pi_monte_carlo_estimation.py
Co-authored-by: John Law <johnlaw.po@gmail.com>
* spelling corrections
* review
* improved documentation, removed redundant variables, added testing
* added type hint
* camel case to snake case
* spelling fix
* review
* python --> Python # it is a brand name, not a snake
* explicit cast to int
* spaces in int list
* "!= None" to "is not None"
* Update comb_sort.py
* various spelling corrections in documentation & several variables naming conventions fix
* + char in file name
* import dependency - bug fix
Co-authored-by: John Law <johnlaw.po@gmail.com>
* estimate area under a curve defined by non-negative real-valued continuous function within a continuous interval using monte-carlo
* run black; update comments
* Use f”strings” and drop unnecessary returns
Co-authored-by: Christian Clauss <cclauss@me.com>
* add example to estimate area under line using montecarlo
* separate estimate func and print statements
* use mean from stats package
* avoid creating extra variable
* min_value: float=0.0, max_value: float=1.0
* Update montecarlo.py
* Update montecarlo.py
* Rename montecarlo.py to monte_carlo.py
* Update monte_carlo.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Add Chudnovskys algorithm for calculating many digits of pi
* Update return value type hint
* Initialize partial sum to be of type Decimal
* Update chudnovsky_algorithm.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Create Bisection.py
Find root of
* Update Bisection.py
* Update Bisection.py
i changed the given function with one that i could make the doctests.
* Rename Bisection.py to bisection.py
* Update bisection.py
* Update bisection.py
* Update bisection.py
* Update bisection.py
* Update bisection.py
Made the changes that were requested
* Update bisection.py
* Update bisection.py
* Add wiki url
Co-authored-by: Christian Clauss <cclauss@me.com>
* Added montecarlo.py
This algorithm uses a Monte Carlo simulation to estimate the value of pi.
* Rename montecarlo.py to maths/montecarlo.py
* Add files via upload
* Delete montecarlo.py
* Rename montecarlo.py to maths/montecarlo.py
* Update montecarlo.py
- Add more doctests and type checking to make sure only natural
numbers are used
- Simplified the algorithm slightly
This new verison is also between 10-15% faster for really
long sequences
* A recursive insertion sort
* added doctests and typehints
* Added arc length and numerical integration calculators
* fixed doc test
* Fixed some conversion errors
* Fixed some commenting
* Deleted numerical integration to allow 1 file per push
* Changed string formatting method
* Added program to calculate trapezoidal area under curve
* Deleted files ensure 1 pull request per file
* file name changed
* Update area_under_curve.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Added to maths and strings
* added changes suggest by cclauss
* added square root function
* Fixed type hinting
* fixed type error
* Fixed another type error
* update volumes with type hints + some refactoring
* added docstrings
* Use float instead of ints in doctest results
Co-authored-by: Christian Clauss <cclauss@me.com>
* Added binary exponentiaion with respect to modulo
* Added miller rabin: the probabilistic primality test for large numbers
* Removed unused import
* Added test for miller_rabin
* Add test to binary_exp_mod
* Removed test parameter to make Travis CI happy
* unittest.main() # doctest: +ELLIPSIS ...
* Update binary_exp_mod.py
* Update binary_exp_mod.py
* Update miller_rabin.py
* from .prime_check import prime_check
Co-authored-by: Christian Clauss <cclauss@me.com>
* Harmonic Geometric and P-Series Added
* Editing comments
* Update and rename series/Geometric_Series.py to maths/series/geometric_series.py
* Update and rename series/Harmonic_Series.py to maths/series/harmonic_series.py
* Update and rename series/P_Series.py to maths/series/p_series.py
* improved prime numbers implementation
* fixup! Format Python code with psf/black push
* fix type hint
* fixup! Format Python code with psf/black push
* fix doctests
* updating DIRECTORY.md
* added prime tests with negative numbers
* using for instead filter
* updating DIRECTORY.md
* Remove unused typing.List
* Remove tab indentation
* print("Sorted order is:", " ".join(a))
* Factors of a number
* Update factors.py
* Fix mypy issue in basic_maths.py
* Fix mypy error in perceptron.py
* def primes(max: int) -> List[int]:
* Update binomial_heap.py
* Add a space
* Remove a space
* Add a space
* Another method added for GCD
* Now doctest fulfilled for added method.
* Update greatest_common_divisor.py
* Now unnecessary white spaces removed.
* Cycle_Detection_Undirected_Graph
Cycle_Detection_Undirected_Graph using Disjoint set DataStructure
* Update greatest_common_divisor.py again
* Again Updated cycle_detection_undirected_graph.py
* Delete cycle_detection_undirected_graph.py
* Add doctests and format the code with psf/black
* fixup: Typo
* Update greatest_common_divisor.py
* greatest_common_divisor()
* some pytest on math folder
* Run the test function via a doctest
Also format the code with psf/black as discussed in CONTRIBUTING.md
* Update abs.py
* Update average_mean.py
* Implementation of Hardy Ramanujan Algorithm
* added docstrings
* added doctests
* Run Python black on the code
* Travis CI: Upgrade to Python 3.8
* Revert to Python 3.7
* renamed module to extend the acronym
* add type hints (will not work with Python less than 3.4)
* update docstring
* refactor the function
* add unittests for the least common squares multiple