Commit Graph

430 Commits

Author SHA1 Message Date
Sanders Lin
c2f2fa8b23 Update abs_Min.py (#1004)
* Update abs_Min.py

* Create __init__.py

* Rename abs_Min.py to abs_min.py

* Update abs_min.py
2019-07-11 18:20:41 +02:00
Alfonso Rodríguez Pereira
5f991f7740 #315 Renamed all files to snake_case (#993) 2019-07-11 11:16:42 +02:00
Sanders Lin
b79a197e8c Update abs_Max.py (#997)
* Update abs_Max.py

fix docstring for doctest to work properly (add space after >>>)

* Update abs_Max.py
2019-07-11 06:43:03 +02:00
Sanders Lin
37fbd8ca2e Update average_median.py (#998)
added doctest, fixed TypeError: list indices must be integers or slices, not float error due to number/2 producing float as index.
2019-07-10 22:38:10 +02:00
PatOnTheBack
897f1d0fb4 Improved Formatting and Style of Math Algos (#960)
* Improved Formatting and Style

I improved formatting and style to make PyLama happier.

Linters used:

- mccabe
- pep257
- pydocstyle
- pep8
- pycodestyle
- pyflakes
- pylint
- isort

* Create volume.py

This script calculates the volumes of various shapes.

* Delete lucasSeries.py

* Revert "Delete lucasSeries.py"

This reverts commit 64c19f7a6c.

* Update lucasSeries.py
2019-07-10 22:09:24 +02:00
PatOnTheBack
add1aef064 Rename average.py to average_mean.py (#939)
'average.py' is ambiguous. There are several kinds of averages, so 'average_mean.py' is a more precise name.
2019-07-10 07:21:04 +02:00
PatOnTheBack
2b365284c8 Removed Unnecessary Assignment for 'error' Var (#920)
`error = abs(f(a))` was declared on line 24 and line 32. It is unnecessary to have in both places.
I removed the second instance since it wastes resources to keep redefining the variable inside the for loop.
This fixes an [issue found by lgtm](66c4afbd0f/files/maths/newton_raphson.py)
2019-07-07 23:45:42 +08:00
Anup Kumar Panwar
4e413c0183 Updated README 2019-07-06 11:11:20 +05:30
PatOnTheBack
1c9d995b9e Implement Three New Algorithms (#948)
* Create average_median.py

I created a program to calculate the median of a list of numbers.

* Changed Odd to Even in String

* Create decimal_to_binary.py

- Added 'conversions' folder.
- Created a decimal to binary converter.

* Implemented Decimal to Octal Algorithm

- I created a decimal to octal converter based on the converter in the TheAlgorithms/Python project.
- I added two newlines to make the output of decimal_to_binary.py better.
2019-07-05 14:06:48 +05:30
PatOnTheBack
a2236cfb97 Improve Formatting and Code Quality (#934)
* Improved Formatting of basic_maths.py

- Added docstrings.
- Improved whitespace formatting.
- Renamed functions to match snake_case.

* Improved Formatting of factorial_python.py

- Added docstrings.
- Improved whitespace formatting.
- Renamed constants to match UPPER_CASE.

* Improved Formatting of factorial_recursive.py

- Improved whitespace formatting to meet PyLint standards.

* Improved Code to Conform to PyLint

- Renamed `max` to `max_num` to avoid redefining built-in 'max' [pylint]
- Removed unnecessary parens after 'while' keyword [pylint]

* Improved Formatting of factorial_recursive.py

- Added docstrings.
- Improved whitespace formatting.
2019-07-02 09:35:43 +05:30
PatOnTheBack
bd4017928e Added Whitespace and Docstring (#924)
* Added Whitespace and Docstring

I modified the file to make Pylint happier and make the code more readable.

* Beautified Code and Added Docstring

I modified the file to make Pylint happier and make the code more readable.

* Added DOCSTRINGS, Wikipedia link, and whitespace

I added DOCSTRINGS and whitespace to make the code more readable and understandable.

* Improved Formatting

* Wrapped comments
* Fixed spelling error for `movement` variable
* Added DOCSTRINGs

* Improved Formatting

* Corrected whitespace to improve readability.
* Added docstrings.
* Made comments fit inside an 80 column layout.
2019-07-01 16:10:18 +08:00
Adeoti Ayodeji
12a16d63b7 Update average.py (#908)
Reduced lines of code and extra processing on the line: n += 1
2019-06-22 12:42:28 +08:00
guij15
066f37402d Update newton_raphson.py (#891) 2019-06-10 12:16:36 +05:30
StephenGemin
9b945cb2b4 Iterative fibonacci with unittests from slash (#882)
* iterative and formula fibonacci methods

Added two ways to calculate the fibonacci sequence:  (1) iterative  (2) formula.  

I've also added a timer decorator so someone can see the difference in computation time between these two methods.  

Added two unittests using the slash framework.

* Update test_fibonacci.py

* remove inline comments per Contributing Guidelines

* Update sol5.py

* Create placeholder.py

* Update and rename maths/test_fibonacci.py to maths/tests/test_fibonacci.py

* Delete placeholder.py

* Create __init__.py

* Update test_fibonacci.py

* Rename Maths/lucasSeries.py to maths/lucasSeries.py

* Update and rename Project Euler/Problem 01/sol5.py to project_euler/problem_01/sol6.py
2019-06-08 20:25:34 +08:00
Erfan Alimohammadi
fc95e7a91a Fermat's little theorem (#847)
* Fix typo

* Add fermat's little theorem

* Update fermat_little_theorem.py

* Fix comments

* Add Wikipedia reference
2019-05-28 20:51:48 +08:00
Anup Kumar Panwar
71be23999c refactor 2019-05-26 21:56:10 +05:30
Julien Castiaux
36828b106f [FIX] maths/PrimeCheck (#796)
Current implementation is buggy and hard to read.

* Negative values were raising a TypeError due to `math.sqrt`
* 1 was considered prime, it is not.
* 2 was considered not prime, it is.

The implementation has been corrected to fix the bugs and to enhance
readability.

A docstring has been added with the definition of a prime number.

A complete test suite has been written, it tests the 10 first primes, a
negative value, 0, 1 and some not prime numbers.

closes #795
2019-05-11 19:20:25 +08:00
Junth Basnet
56513cb21f add-binary-exponentiation (#790) 2019-05-10 19:03:05 +08:00
Vysor
df04d94543 Some directories had a capital in their name [fixed]. Added a recursive factorial algorithm. (#763)
* Renaming directories
* Adding a recursive factorial algorithm
2019-04-22 22:53:56 +08:00
WILFRIED NJANGUI
b2f1d9c337 implementation of tower_of_hanoi algorithm (#756) 2019-04-14 19:58:16 +08:00
Reshad Hasan
9a44eb4479 Organize graph algorithms (#719)
* organized graph algorithms

* all graph algorithms in Graphs/ folder

* all graph algorithms are in one folder

* Rename number theory/factorial_python.py to maths/factorial_python.py
2019-02-25 17:35:24 +08:00
P-Shreyas-Shetty
02f850965d Implementation of Newton-Raphson method (#650)
Implemented Newton-Raphson method using pure python. Third party library is used only for visualizing error variation with each iteration.
2019-02-12 00:15:49 +08:00
Harshil
5db9d2e54a Merge branch 'master' of git://github.com/gerroo/Python into gerroo-master 2018-11-04 16:04:29 +01:00
gerroo
a834326e0e Added b16, b32, a85, abs, absMax, absMin 2018-11-03 12:08:13 -08:00
dheerajreddymumma
1305e74b8a New modified Python code for Prime check 2018-10-28 17:02:27 +05:30
dheerajreddymumma
2040757751 Optimized prime check code in Python. 2018-10-28 16:53:56 +05:30
Alex Brown
ea2ddaaf6a all valid python 3 2018-10-20 14:45:08 -05:00
Alex Brown
b566055e4b Merge branch 'master' of https://github.com/TheAlgorithms/Python 2018-10-20 14:15:21 -05:00
Alex Brown
91fccecb56 snake_case all the things 2018-10-19 17:14:25 -05:00
Alex Brown
564179a0ec increment 1 2018-10-19 07:48:28 -05:00