Skip to content

adding jaccard similarity (TheAlgorithms#1270) #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 193 commits into from
Oct 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
193 commits
Select commit Hold shift + click to select a range
f9b8dbf
Correct the wrong iterative DFS implementation (#867)
ZJUGuoShuai Jun 4, 2019
0f229e0
Atbash.py: Both raw_input() and unichr() were removed in Python 3 (#855)
cclauss Jun 5, 2019
ebe227c
Removed Graphs and move prim.py to graphs (#872)
NielXu Jun 5, 2019
6e894ba
Odd-Even Transposition Sort (#769)
CharlesRitter Jun 7, 2019
9b945cb
Iterative fibonacci with unittests from slash (#882)
StephenGemin Jun 8, 2019
066f374
Update newton_raphson.py (#891)
guij15 Jun 10, 2019
05e5172
.vs/ directory, matrix_multiplication_addition file and binary tree d…
qckzr Jun 11, 2019
af1925b
Remove empty folder in analysis/compression_analysis (#897)
StephenGemin Jun 12, 2019
1b3affc
fix typo (#902)
Erfaniaa Jun 15, 2019
6e2fb22
Problem 234 project Euler (#883)
archithadge Jun 16, 2019
55e0b0f
Corrected wrong DFS implementation (#903)
ziyzhu Jun 17, 2019
ef14748
Added script for automatically generating DIRECTORY.md (#889)
NielXu Jun 17, 2019
b893736
Fixed typo and capitalized some words (#900)
qckzr Jun 18, 2019
a99acae
Add docstring and comments per Issue #727 (#895)
StephenGemin Jun 18, 2019
12a16d6
Update average.py (#908)
lordsarcastic Jun 22, 2019
a212efe
Corrected wrong Dijkstra priority queue implementation (#909)
ziyzhu Jun 23, 2019
b7cff04
better implementation for midpoint (#914)
wuminbin Jun 24, 2019
be4150c
Create spiralPrint.py (#844)
brajesh-rit Jun 26, 2019
34889fc
Update quick_sort.py (#928)
BruceLee569 Jun 28, 2019
2333f93
Change Declaration of Var 'j' to None (#921)
PatOnTheBack Jun 30, 2019
bd40179
Added Whitespace and Docstring (#924)
PatOnTheBack Jul 1, 2019
a2236cf
Improve Formatting and Code Quality (#934)
PatOnTheBack Jul 2, 2019
27a8184
add ons in string directory - Bayer_Moore_Search (#933)
Dharni0607 Jul 2, 2019
0f56ab5
Divide and conquer Algorithms Issue#817 (#938)
Dharni0607 Jul 2, 2019
65a12fa
Adding sum of subsets (#929)
jpg-130 Jul 2, 2019
4fb4cb4
Travis CI: Simplify the testing (#887)
cclauss Jul 3, 2019
03f9940
Refactored to one pop() (#917)
kgashok Jul 3, 2019
035457f
closest pair of points algo (#943)
Dharni0607 Jul 4, 2019
05fc7f8
Added '~script.py' to ignore files and updated DIRECTORY.md (#926)
qckzr Jul 4, 2019
408c5de
add gaussian filter algorithm and lena.jpg (#955)
lighttxu Jul 5, 2019
217615a
Removed Unused Variables (#949)
PatOnTheBack Jul 5, 2019
1c9d995
Implement Three New Algorithms (#948)
PatOnTheBack Jul 5, 2019
506bb5c
Add Red-Black Binary Search Trees (#954)
JarredAllen Jul 5, 2019
afb98e6
KNN (#944)
Dhandarah Jul 5, 2019
831558d
#945 Backtracking Algorithms (#953)
Jul 5, 2019
4e413c0
Updated README
AnupKumarPanwar Jul 6, 2019
f30f849
Updated README
AnupKumarPanwar Jul 6, 2019
b238340
refactor
AnupKumarPanwar Jul 6, 2019
1161393
updated CONTRIBUTING.md
AnupKumarPanwar Jul 6, 2019
aa66303
Create FUNDING.yml
AnupKumarPanwar Jul 6, 2019
1951b4c
Update FUNDING.yml
AnupKumarPanwar Jul 6, 2019
cc4cf3e
Generate all subsequences using backtracking (#961)
Erfaniaa Jul 6, 2019
839160f
Generate all permutations of a sequence, using backtracking (#962)
Erfaniaa Jul 6, 2019
781b7f8
Fix readme and duplicate (#967)
Erfaniaa Jul 6, 2019
69bed59
Fix backtrack time complexity (#965)
Erfaniaa Jul 6, 2019
26df2aa
Removed Unused `import sys` (#922)
PatOnTheBack Jul 6, 2019
4ff2a9d
minimax (#947)
aditiagarwal34550 Jul 7, 2019
9532492
added enigma machine algorithm (#932)
shahabmohammadi Jul 7, 2019
234b0a7
Simplied password_generator.py (#968)
qckzr Jul 7, 2019
2b36528
Removed Unnecessary Assignment for 'error' Var (#920)
PatOnTheBack Jul 7, 2019
b7f13d9
Travis CI: Run black, doctest, flake8, mypy, and pytest (#964)
cclauss Jul 8, 2019
78cd3df
Update CONTRIBUTING.md to match #964 (#969)
cclauss Jul 8, 2019
32d5c1a
Project Euler Problem #13 Python Solution (#935)
Blues1998 Jul 8, 2019
e2d9953
convolve and sobel (#971)
lighttxu Jul 8, 2019
8b2d1b7
added decimal to hexadecimal conversion (#977)
jasper256 Jul 9, 2019
c85312d
updates in closest pair of points algorithm (#979)
Dharni0607 Jul 9, 2019
e6eaa07
Pytest the entire repo (#980)
cclauss Jul 10, 2019
add1aef
Rename average.py to average_mean.py (#939)
PatOnTheBack Jul 10, 2019
34dee74
add canny edge detection algorithm and modify sobel_filter (#991)
lighttxu Jul 10, 2019
2ad5be9
Modified Docstrings to Fix Errors (#975)
PatOnTheBack Jul 10, 2019
897f1d0
Improved Formatting and Style of Math Algos (#960)
PatOnTheBack Jul 10, 2019
37fbd8c
Update average_median.py (#998)
SandersLin Jul 10, 2019
b79a197
Update abs_Max.py (#997)
SandersLin Jul 11, 2019
5f991f7
#315 Renamed all files to snake_case (#993)
Alfro Jul 11, 2019
c2f2fa8
Update abs_Min.py (#1004)
SandersLin Jul 11, 2019
f2eb965
Update ~script.py (#990)
FrogBattle Jul 11, 2019
1dc9ec8
Update Bucket Sort time complexity analysis (#918)
obelisk0114 Jul 12, 2019
1e0b33d
Update 3n+1.py (#996)
SandersLin Jul 13, 2019
7a6ebb8
Update edit_distance.py (#1001)
SandersLin Jul 13, 2019
7271c0d
Update rod_cutting.py (#995)
SandersLin Jul 13, 2019
d72586c
Updated ~script.py per #978 (#1013)
qckzr Jul 13, 2019
0d61539
Log_likelihood update (#1008)
ChillOrb Jul 13, 2019
628794d
Add combinations (#1015)
obelisk0114 Jul 14, 2019
3b2738e
Add rotate matrix problem (#1021)
obelisk0114 Jul 15, 2019
1e55bfd
Create climbing_stairs.py (#1002)
SandersLin Jul 15, 2019
2fb3bee
Fix error message and format with python/black (#1025)
cclauss Jul 16, 2019
267b5ef
Added doctest and more explanation about Dijkstra execution. (#1014)
brunohadlich Jul 16, 2019
7cdda93
Travis CI: Add pytest --doctest-modules graphs (#1018)
cclauss Jul 17, 2019
f195d92
adding factorial (#930)
jpg-130 Jul 17, 2019
f64b602
Update max_sub_array.py (#1000)
SandersLin Jul 17, 2019
e662a5a
Added Burrows-Wheeler transform algorithm. (#1029)
brunohadlich Jul 17, 2019
4658f4a
lgtm fixes (#1032)
jpg-130 Jul 18, 2019
c2e8582
Travis CI: Add pytest --doctest-modules neural_network (#1028)
cclauss Jul 18, 2019
9a55f2b
Remove the space: lucas series.py --> lucas_series.py (#1036)
cclauss Jul 18, 2019
f438440
Fixes for issue "Fix the LGTM issues #1024" (#1034)
brunohadlich Jul 18, 2019
9f8953d
Update find_lcm.py (#1019)
thiru15 Jul 18, 2019
f7ac8b5
Commented doctests that were causing slowness at Travis. (#1039)
brunohadlich Jul 18, 2019
9fcfe6a
Commented doctests that were causing slowness at Travis. #2 (#1041)
brunohadlich Jul 19, 2019
60c608d
Added matrix exponentiation approach for finding fibonacci number. (#…
mahbubcseju Jul 19, 2019
dc1de94
Use correct function names in nth_fibonacci_using_matrix_exponentiati…
cclauss Jul 19, 2019
4e0717c
Add error & test checks for matrix_operations.py (#925)
StephenGemin Jul 20, 2019
f5e6d4e
Update DIRECTORY.md (#1046)
cclauss Jul 20, 2019
61fec83
Adds Gaussian Function in maths section (#1054)
QuantumNovice Jul 20, 2019
5b5beb6
Update newton_raphson_method.py (#1057)
QuantumNovice Jul 20, 2019
0f09530
dijkstra.py: Use r"strings" to fix two pylint warnings (#1052)
cclauss Jul 20, 2019
b35f5d9
Update CONTRIBUTING.md (#1059)
poyea Jul 20, 2019
93fdc9f
Travis CI: Add pytest --doctest-modules maths (#1020)
cclauss Jul 21, 2019
c964d74
Added Mobius Function (#1058)
QuantumNovice Jul 21, 2019
05e567c
Code to change contrast (#1060)
QuantumNovice Jul 21, 2019
b2ed8d4
rotate_matrix.py: Add type hints for return values (#1023)
cclauss Jul 22, 2019
7c3ef98
Implement ruling hash to appropriate complexity of Rabin Karp (#1066)
mahbubcseju Jul 24, 2019
46bcee0
Add badges to the top of README.md (#1064)
QuantumNovice Jul 24, 2019
3c8e931
Travis CI: Add a flake8 test for unused imports (#1038)
cclauss Jul 25, 2019
c27bd51
in_static_equilibrium checks if a 2D static system is in equilibrium …
QuantumNovice Jul 25, 2019
46bc673
Add doctest to maths/sieve_of_eratosthenes.py and remove other/findin…
obelisk0114 Jul 26, 2019
3b63857
added automated doctest to decimal_to_hexadecimal.py in conversions (…
jasper256 Jul 26, 2019
a0817bd
Rewrite build_directory_md.py (#1076)
cclauss Jul 28, 2019
7b2c954
LargestOfVeryLargeNumbers (#818)
abhikmp Jul 30, 2019
a9ecdb3
Validate Python filenames (#1086)
cclauss Jul 30, 2019
861a8c3
Add Lucas_Lehmer_primality_test (#1050)
obelisk0114 Jul 30, 2019
e58a5e6
Update tim_sort.py (#972)
FrogBattle Jul 30, 2019
4a5589f
project_euler/problem_10 (#1089)
itsvinayak Jul 31, 2019
7b267e5
Fix data_structures to pass our Travis CI pytests (#1088)
cclauss Jul 31, 2019
9c0cbe3
Create collatz_sequence.py (#639)
SandersLin Aug 1, 2019
e313141
bin(num). convert ZERO and negative decimal numbers to binary. (#1093)
syedwaleedhyder Aug 3, 2019
bdbe682
Zeller's Congruence Algorithm (#1095)
mrvnmchm Aug 5, 2019
87a789a
Boolean algebra pytests (#1097)
mrvnmchm Aug 5, 2019
4437439
Added Unicode test to strings/rabin_karp.py (#1096)
qckzr Aug 5, 2019
47bc34a
Added pytests to sha1.py (#1098)
QuantumNovice Aug 6, 2019
22d2453
Create Quadratic Equations(Complexes Numbers) (#941)
AugustofCravo Aug 6, 2019
5812640
pytests for closest_pair_of_points.py (#1099)
rsun0013 Aug 6, 2019
6654e1e
remove from __future__, propre filename (#1102)
harshildarji Aug 6, 2019
89acf5d
print() is a function just like every other function (#1101)
cclauss Aug 6, 2019
d21b4cf
Added pytests to hashes/md5.py (#1100)
QuantumNovice Aug 6, 2019
762482d
Update closest_pair_of_points.py (#1109)
harshildarji Aug 6, 2019
7b5a184
print() is a function just like every other function (#1104)
cclauss Aug 6, 2019
7cf3db1
Add test for QuadraticEquation() (#1107)
cclauss Aug 6, 2019
561a414
Travis CI: Run each failing pytest in allow_failures mode (#1087)
cclauss Aug 6, 2019
9456e81
Seperate client and server of FTP (#1106)
AlexDvorak Aug 7, 2019
c92d06b
Delete redundant files (#1115)
poyea Aug 7, 2019
32c0418
Infinite loop was fixed. (#1105)
AmritK10 Aug 7, 2019
3ba67c7
rename non-ftp files (#1116)
AlexDvorak Aug 7, 2019
c686cc5
fix outdated fork error (#1117)
mrvnmchm Aug 8, 2019
91c3c98
Rename file_transfer and linear_algebra (#1118)
cclauss Aug 9, 2019
36684db
Travis CI: Add pytest --doctest-modules machine_learning (#1016)
cclauss Aug 10, 2019
55cea57
Fix tests for file_transfer and perceptron.py (#1121)
cclauss Aug 11, 2019
158b319
New linear algebra algorithm (#1122)
nic-dern Aug 12, 2019
4fea480
Add type hints to binary_tree_traversals.py (#1123)
cclauss Aug 12, 2019
c74fd0c
Add maths/test_prime_check.py (#1125)
cclauss Aug 13, 2019
dc2b575
Add doctests to networking_flow/minimum_cut.py (#1126)
cclauss Aug 13, 2019
f3c0b13
Added sudoku solving program in backtracking algorithms (#1128)
adithbharadwaj Aug 13, 2019
8eab2f1
Solution for Problem Euler 56 (#1131)
shuklalok Aug 13, 2019
27205d4
Update DIRECTORY.md (#1129)
cclauss Aug 14, 2019
3e69733
Remove 'python' from the filename (#1130)
cclauss Aug 15, 2019
5bdcd48
EHN: A divide-and-conquer, and brute-force algorithms for array inver…
maxwell-aladago Aug 15, 2019
a18a8fe
Update .gitignore to remove __pycache__/ (#1127)
cclauss Aug 16, 2019
05c9a05
ENH: two algorithms for the convex hull problem of a set of 2d points…
maxwell-aladago Aug 17, 2019
5d46a4d
ENH: Added a functionality to make it possible to reconstruct an opti…
maxwell-aladago Aug 19, 2019
32aa7ff
ENH: refactored longest common subsequence, also fixed a bug with the…
maxwell-aladago Aug 19, 2019
47a9ea2
Simplify code by dropping support for legacy Python (#1143)
cclauss Aug 19, 2019
2304e31
Fixing lgtm issue in basic graphs (#1141)
qckzr Aug 20, 2019
47cb394
added doctests for compare_string and is_for_table (#1138)
pathak-deep15 Aug 22, 2019
e694e59
Added a few doctests for traversals (#1149)
naklecha Aug 25, 2019
2f8516e
implementation of sorted vector machines (#1156)
anand-371 Aug 28, 2019
82a079c
add .github/stale.yml (#1158)
harshildarji Aug 28, 2019
d327f10
Update stale.yml
r0hit-gupta Aug 28, 2019
d4151bd
Fix possible error in longest_common_subsequence.py (#1163)
rwithik Aug 31, 2019
d567a9e
solution to problem 551 from project euler (#1164)
b63 Sep 1, 2019
9492e7a
Created Sherman Morrison method (#1162)
McDic Sep 3, 2019
a4ed40b
changing typo (#1168)
maxwell-aladago Sep 4, 2019
f31a812
Add Binomial Heap (#1146)
KirilBangachev Sep 5, 2019
2dfe01e
Fully refactored the rod cutting module. (#1169)
maxwell-aladago Sep 5, 2019
ab25079
Update DIRECTORY (#1161)
jai-dewani Sep 6, 2019
a41a14f
Add radix2 FFT (#1166)
KirilBangachev Sep 6, 2019
5b483be
Added OOP approach to matrices (#1165)
jasper256 Sep 8, 2019
3c3f92d
Add problem 67 solution (#1170)
Hyftar Sep 8, 2019
030600f
Update matrix_class.py (#1175)
cclauss Sep 10, 2019
47d1795
Add Kth lexicographic permutation (#1179)
KirilBangachev Sep 13, 2019
f8e30cf
Digital Image Processing Tests (#1178)
mrvnmchm Sep 13, 2019
6fa3c0b
Add Flake8 F4 Tests to .travis.yml (#974)
PatOnTheBack Sep 13, 2019
768700b
Add delete to trie.py + tests (#1177)
ksangeet9ap Sep 13, 2019
a2b5a90
Added sequential minimum optimization algorithm for SVM (#508)
zqbake Sep 18, 2019
04962c0
Fix lgtm error display #1024 (#1190)
denis-trofimov Sep 21, 2019
837bfff
Rename sorted_vector_machines.py to support_vector_machines.py (#1195)
Holden-Lin Sep 22, 2019
01601e6
Add disjoint set (#1194)
luoheng23 Sep 23, 2019
e40d4a2
Added Matrix Exponentiation (#1203)
anirudnits Sep 25, 2019
6ac7b13
Min head with decrease key functionality (#1202)
Raj1998 Sep 25, 2019
2375bfb
Adding stooge sort (#1206)
Charitoc Sep 26, 2019
a79fc2b
Fix the build typo: fn --> fn1 (#1205)
cclauss Sep 26, 2019
4617aa7
DBSCAN algorithm (#1207)
cozek Sep 29, 2019
189b350
Deque (#1200)
Sep 30, 2019
b738281
maths-polynomial_evalutation (#1214)
msk4862 Oct 1, 2019
df44d1b
Update CONTRIBUTING.md (#1250)
cclauss Oct 2, 2019
b8490ed
Removed owners from README (#1254)
AnupKumarPanwar Oct 3, 2019
390feb0
Add doctests for sorting algorithms (#1263)
parth-paradkar Oct 3, 2019
0e333ae
added bogobogosort (#1258)
WilliamHYZhang Oct 3, 2019
0e2d6b2
adding softmax function (#1267)
cozek Oct 3, 2019
03aba96
added defination (#1244)
shubhamgarg2000 Oct 3, 2019
f970c73
Add problem 23 solution (#1261)
Hyftar Oct 3, 2019
d28fc71
Add problem18 solution (#1260)
Hyftar Oct 3, 2019
6e69208
Add problem 32 solution (#1257)
Hyftar Oct 3, 2019
309204a
Add problem 42 solution (#1259)
Hyftar Oct 3, 2019
07f04a2
adding jaccard similarity (#1270)
cozek Oct 4, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
12 changes: 12 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# These are supported funding model platforms

github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: TheAlgorithms
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: ['http://paypal.me/TheAlgorithms/1000', 'https://donorbox.org/thealgorithms']
18 changes: 18 additions & 0 deletions .github/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 30
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 7
# Issues with these labels will never be considered stale
exemptLabels:
- bug
- help wanted
- OK to merge
# Label to use when marking an issue as stale
staleLabel: wontfix
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: true
34 changes: 25 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ __pycache__/
*.so

# Distribution / packaging
.vscode/
.Python
env/
build/
develop-eggs/
dist/
Expand All @@ -21,9 +19,11 @@ lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
Expand All @@ -43,8 +43,9 @@ htmlcov/
.cache
nosetests.xml
coverage.xml
*,cover
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
Expand All @@ -53,6 +54,7 @@ coverage.xml
# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
Expand All @@ -67,7 +69,7 @@ docs/_build/
# PyBuilder
target/

# IPython Notebook
# Jupyter Notebook
.ipynb_checkpoints

# pyenv
Expand All @@ -76,18 +78,32 @@ target/
# celery beat schedule file
celerybeat-schedule

# dotenv
.env
# SageMath parsed files
*.sage.py

# virtualenv
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject
.idea

# mkdocs documentation
/site

# mypy
.mypy_cache/

.DS_Store
.try
.idea
.try
.vscode/
12 changes: 0 additions & 12 deletions .lgtm.yml

This file was deleted.

34 changes: 12 additions & 22 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,16 @@
language: python
dist: xenial # required for Python >= 3.7
python: 3.7
cache: pip
python:
- 2.7
- 3.6
#- nightly
#- pypy
#- pypy3
matrix:
allow_failures:
- python: nightly
- python: pypy
- python: pypy3
install:
#- pip install -r requirements.txt
- pip install flake8 # pytest # add another testing frameworks later
before_install: pip install --upgrade pip setuptools
install: pip install -r requirements.txt
before_script:
# stop the build if there are Python syntax errors or undefined names
- flake8 . --count --select=E9,F63,F72,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
- flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- black --check . || true
- flake8 . --count --select=E9,F4,F63,F7,F82 --show-source --statistics
script:
- true # pytest --capture=sys # add other tests here
notifications:
on_success: change
on_failure: change # `always` will be the setting once code changes slow down
- scripts/validate_filenames.py # no uppercase, no spaces, in a directory
- mypy --ignore-missing-imports .
- pytest . --doctest-modules
after_success:
- scripts/build_directory_md.py > DIRECTORY.md
- cat DIRECTORY.md
Binary file removed .vs/Python/v15/.suo
Binary file not shown.
Binary file removed .vs/slnx.sqlite
Binary file not shown.
115 changes: 72 additions & 43 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ Welcome to [TheAlgorithms/Python](https://github.com/TheAlgorithms/Python)! Befo

We are very happy that you consider implementing algorithms and data structure for others! This repository is referenced and used by learners from all over the globe. Being one of our contributors, you agree and confirm that:

- your did your work - no plagiarism allowed
- You did your work - no plagiarism allowed
- Any plagiarized work will not be merged.
- your work will be distributed under [MIT License](License) once your pull request is merged
- you submitted work fulfils or mostly fulfils our styles and standards
- Your work will be distributed under [MIT License](License) once your pull request is merged
- You submitted work fulfils or mostly fulfils our styles and standards

**New implementation** is welcome! For example, new solutions for a problem, different representations for a graph data structure or algorithm designs with different complexity.

Expand All @@ -23,19 +23,38 @@ We are very happy that you consider implementing algorithms and data structure f

We appreciate any contribution, from fixing a grammar mistake in a comment to implementing complex algorithms. Please read this section if you are contributing your work.

Your contribution will be tested by our [automated testing on Travis CI](https://travis-ci.org/TheAlgorithms/Python/pull_requests) to save time and mental energy. After you have submitted your pull request, you should see the Travis tests start to run at the bottom of your submission page. If those tests fail, then click on the ___details___ button try to read through the Travis output to understand the failure. If you do not understand, please leave a comment on your submission page and a community member will try to help.

#### Coding Style

We want your work to be readable by others; therefore, we encourage you to note the following:

- Please write in Python 3.x.
- Please write in Python 3.7+. __print()__ is a function in Python 3 so __print "Hello"__ will _not_ work but __print("Hello")__ will.

- Please focus hard on naming of functions, classes, and variables. Help your reader by using __descriptive names__ that can help you to remove redundant comments.
- Single letter variable names are _old school_ so please avoid them unless their life only spans a few lines.
- Expand acronyms because __gcd()__ is hard to understand but __greatest_common_divisor()__ is not.
- Please follow the [Python Naming Conventions](https://pep8.org/#prescriptive-naming-conventions) so variable_names and function_names should be lower_case, CONSTANTS in UPPERCASE, ClassNames should be CamelCase, etc.

- We encourage the use of Python [f-strings](https://realpython.com/python-f-strings/#f-strings-a-new-and-improved-way-to-format-strings-in-python) where the make the code easier to read.

- If you know [PEP 8](https://www.python.org/dev/peps/pep-0008/) already, you will have no problem in coding style, though we do not follow it strictly. Read the remaining section and have fun coding!
- Please consider running [__psf/black__](https://github.com/python/black) on your Python file(s) before submitting your pull request. This is not yet a requirement but it does make your code more readable and automatically aligns it with much of [PEP 8](https://www.python.org/dev/peps/pep-0008/). There are other code formatters (autopep8, yapf) but the __black__ style is now the recommendation of the Python Core Team. To use it,
```bash
pip3 install black # only required the first time
black .
```

- Always use 4 spaces to indent.
- All submissions will need to pass the test __flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics__ before they will be accepted so if possible, try this test locally on your Python file(s) before submitting your pull request.
```bash
pip3 install flake8 # only required the first time
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
```

- Original code submission requires comments to describe your work.
- Original code submission require docstrings or comments to describe your work.

- More on comments and docstrings:
- More on docstrings and comments:

If you are using a Uncyclopedia article or some other source material to create your algorithm, please add the URL in a docstring or comment to help your reader.

The following are considered to be bad and may be requested to be improved:

Expand All @@ -45,80 +64,90 @@ We want your work to be readable by others; therefore, we encourage you to note

This is too trivial. Comments are expected to be explanatory. For comments, you can write them above, on or below a line of code, as long as you are consistent within the same piece of code.

*Sometimes, docstrings are avoided.* This will happen if you are using some editors and not careful with indentation:
We encourage you to put docstrings inside your functions but please pay attention to indentation of docstrings. The following is acceptable in this case:

```python
def sumab(a, b):
"""
This function returns the sum of two integers a and b
Return: a + b
"""
This function sums a and b
"""
def sum(a, b):
return a + b
```

However, if you insist to use docstrings, we encourage you to put docstrings inside functions. Also, please pay attention to indentation to docstrings. The following is acceptable in this case:
- Write tests (especially [__doctests__](https://docs.python.org/3/library/doctest.html)) to illustrate and verify your work. We highly encourage the use of _doctests on all functions_.

```python
def sumab(a, b):
"""
This function sums two integers a and b
Return: a + b
"""
This function returns the sum of two integers a and b
Return: a + b
>>> sum(2, 2)
4
>>> sum(-2, 3)
1
>>> sum(4.9, 6.1)
10.0
"""
return a + b
```

- `lambda`, `map`, `filter`, `reduce` and complicated list comprehension are welcome and acceptable to demonstrate the power of Python, as long as they are simple enough to read.

- This is arguable: **write comments** and assign appropriate variable names, so that the code is easy to read!

- Write tests to illustrate your work.
These doctests will be run by pytest as part of our automated testing so please try to run your doctests locally and make sure that they are found and pass:
```bash
python3 -m doctest -v my_submission.py
```

The following "testing" approaches are not encouraged:
The use of the Python builtin __input()__ function is **not** encouraged:

```python
input('Enter your input:')
input('Enter your input:')
# Or even worse...
input = eval(raw_input("Enter your input: "))
input = eval(input("Enter your input: "))
```

Please write down your test case, like the following:
However, if your code uses __input()__ then we encourage you to gracefully deal with leading and trailing whitespace in user input by adding __.strip()__ as in:

```python
def sumab(a, b):
return a + b
# Write tests this way:
print(sumab(1,2)) # 1+2 = 3
print(sumab(6,4)) # 6+4 = 10
# Or this way:
print("1 + 2 = ", sumab(1,2)) # 1+2 = 3
print("6 + 4 = ", sumab(6,4)) # 6+4 = 10
starting_value = int(input("Please enter a starting value: ").strip())
```

The use of [Python type hints](https://docs.python.org/3/library/typing.html) is encouraged for function parameters and return values. Our automated testing will run [mypy](http://mypy-lang.org) so run that locally before making your submission.
```python
def sumab(a: int, b: int) --> int:
pass
```

- [__list comprehensions and generators__](https://docs.python.org/3/tutorial/datastructures.html#list-comprehensions) are preferred over the use of `lambda`, `map`, `filter`, `reduce` but the important thing is to demonstrate the power of Python in code that is easy to read and maintain.

- Avoid importing external libraries for basic algorithms. Use those libraries for complicated algorithms.
- Avoid importing external libraries for basic algorithms. Only use those libraries for complicated algorithms.

- If you need a third party module that is not in the file __requirements.txt__, please add it to that file as part of your submission.

#### Other Standard While Submitting Your Work

- File extension for code should be `.py`.
- File extension for code should be `.py`. Jupiter notebook files are acceptable in machine learning algorithms.

- Please file your work to let others use it in the future. Here are the examples that are acceptable:
- Please avoid creating new directories if at all possible. Try to fit your work into the existing directory structue.

- Camel cases
- `-` Hyphenated names
- `_` Underscore-separated names
- Strictly use snake_case (underscore_separated) in your file_name, as it will be easy to parse in future using scripts.

If possible, follow the standard *within* the folder you are submitting to.

- If you have modified/added code work, make sure the code compiles before submitting.

- If you have modified/added documentation work, make sure your language is concise and contains no grammar mistake.
- If you have modified/added documentation work, ensure your language is concise and contains no grammar errors.

- Do not update the README.md or DIRECTORY.md file which will be periodically autogenerated by our Travis CI processes.

- Add a corresponding explanation to [Algorithms-Explanation](https://github.com/TheAlgorithms/Algorithms-Explanation) (Optional but recommended).

- All submissions will be tested with [__mypy__](http://www.mypy-lang.org) so we encourage to add [__Python type hints__](https://docs.python.org/3/library/typing.html) where it makes sense to do so.

- Most importantly,

- **be consistent with this guidelines while submitting.**
- **join** [Gitter](https://gitter.im/TheAlgorithms) **now!**
- **Be consistent in the use of these guidelines when submitting.**
- **Join** [Gitter](https://gitter.im/TheAlgorithms) **now!**
- Happy coding!



Writer [@poyea](https://github.com/poyea), Jun 2019.
Loading