Skip to content

Commit ee41c81

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents e66101f + 2304e31 commit ee41c81

File tree

398 files changed

+19670
-4517
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

398 files changed

+19670
-4517
lines changed

.github/FUNDING.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# These are supported funding model platforms
2+
3+
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4+
patreon: # Replace with a single Patreon username
5+
open_collective: # Replace with a single Open Collective username
6+
ko_fi: # Replace with a single Ko-fi username
7+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9+
liberapay: TheAlgorithms
10+
issuehunt: # Replace with a single IssueHunt username
11+
otechie: # Replace with a single Otechie username
12+
custom: ['http://paypal.me/TheAlgorithms/1000', 'https://donorbox.org/thealgorithms']

.gitignore

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ __pycache__/
77
*.so
88

99
# Distribution / packaging
10-
.vscode/
1110
.Python
12-
env/
1311
build/
1412
develop-eggs/
1513
dist/
@@ -21,9 +19,11 @@ lib64/
2119
parts/
2220
sdist/
2321
var/
22+
wheels/
2423
*.egg-info/
2524
.installed.cfg
2625
*.egg
26+
MANIFEST
2727

2828
# PyInstaller
2929
# Usually these files are written by a python script from a template
@@ -43,8 +43,9 @@ htmlcov/
4343
.cache
4444
nosetests.xml
4545
coverage.xml
46-
*,cover
46+
*.cover
4747
.hypothesis/
48+
.pytest_cache/
4849

4950
# Translations
5051
*.mo
@@ -53,6 +54,7 @@ coverage.xml
5354
# Django stuff:
5455
*.log
5556
local_settings.py
57+
db.sqlite3
5658

5759
# Flask stuff:
5860
instance/
@@ -67,7 +69,7 @@ docs/_build/
6769
# PyBuilder
6870
target/
6971

70-
# IPython Notebook
72+
# Jupyter Notebook
7173
.ipynb_checkpoints
7274

7375
# pyenv
@@ -76,17 +78,32 @@ target/
7678
# celery beat schedule file
7779
celerybeat-schedule
7880

79-
# dotenv
80-
.env
81+
# SageMath parsed files
82+
*.sage.py
8183

82-
# virtualenv
84+
# Environments
85+
.env
86+
.venv
87+
env/
8388
venv/
8489
ENV/
90+
env.bak/
91+
venv.bak/
8592

8693
# Spyder project settings
8794
.spyderproject
95+
.spyproject
8896

8997
# Rope project settings
9098
.ropeproject
99+
100+
# mkdocs documentation
101+
/site
102+
103+
# mypy
104+
.mypy_cache/
105+
106+
.DS_Store
91107
.idea
92-
.DS_Store
108+
.try
109+
.vscode/

.lgtm.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

.travis.yml

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,16 @@
11
language: python
2+
dist: xenial # required for Python >= 3.7
3+
python: 3.7
24
cache: pip
3-
python:
4-
- 2.7
5-
- 3.6
6-
#- nightly
7-
#- pypy
8-
#- pypy3
9-
matrix:
10-
allow_failures:
11-
- python: nightly
12-
- python: pypy
13-
- python: pypy3
14-
install:
15-
#- pip install -r requirements.txt
16-
- pip install flake8 # pytest # add another testing frameworks later
5+
before_install: pip install --upgrade pip setuptools
6+
install: pip install -r requirements.txt
177
before_script:
18-
# stop the build if there are Python syntax errors or undefined names
19-
- flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics
20-
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
21-
- flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
8+
- black --check . || true
9+
- flake8 . --count --select=E9,F401,F63,F7,F82 --show-source --statistics
2210
script:
23-
- true # pytest --capture=sys # add other tests here
24-
notifications:
25-
on_success: change
26-
on_failure: change # `always` will be the setting once code changes slow down
11+
- scripts/validate_filenames.py # no uppercase, no spaces, in a directory
12+
- mypy --ignore-missing-imports .
13+
- pytest . --doctest-modules
14+
after_success:
15+
- scripts/build_directory_md.py > DIRECTORY.md
16+
- cat DIRECTORY.md

.vs/Python/v15/.suo

-16.5 KB
Binary file not shown.

.vs/slnx.sqlite

-172 KB
Binary file not shown.

CONTRIBUTING.md

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
# Contributing guidelines
2+
3+
## Before contributing
4+
5+
Welcome to [TheAlgorithms/Python](https://github.com/TheAlgorithms/Python)! Before sending your pull requests, make sure that you **read the whole guidelines**. If you have any doubt on the contributing guide, please feel free to [state it clearly in an issue](https://github.com/TheAlgorithms/Python/issues/new) or ask the community in [Gitter](https://gitter.im/TheAlgorithms).
6+
7+
## Contributing
8+
9+
### Contributor
10+
11+
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:
12+
13+
- You did your work - no plagiarism allowed
14+
- Any plagiarized work will not be merged.
15+
- Your work will be distributed under [MIT License](License) once your pull request is merged
16+
- You submitted work fulfils or mostly fulfils our styles and standards
17+
18+
**New implementation** is welcome! For example, new solutions for a problem, different representations for a graph data structure or algorithm designs with different complexity.
19+
20+
**Improving comments** and **writing proper tests** are also highly welcome.
21+
22+
### Contribution
23+
24+
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.
25+
26+
#### Coding Style
27+
28+
We want your work to be readable by others; therefore, we encourage you to note the following:
29+
30+
- Please write in Python 3.x.
31+
- Please consider running [__python/black__](https://github.com/python/black) on your Python file(s) before submitting your pull request. This is not a requirement but it does make your code more readable. There are other code formatters (autopep8, yapf) but the __black__ style is now the recommendation of the Python core team. To use it,
32+
```bash
33+
pip3 install black # only required the first time
34+
black my-submission.py
35+
```
36+
37+
- 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.
38+
39+
- 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!
40+
41+
- Always use 4 spaces to indent.
42+
43+
- Original code submission requires comments to describe your work.
44+
45+
- More on comments and docstrings:
46+
47+
The following are considered to be bad and may be requested to be improved:
48+
49+
```python
50+
x = x + 2 # increased by 2
51+
```
52+
53+
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.
54+
55+
*Sometimes, docstrings are avoided.* This will happen if you are using some editors and not careful with indentation:
56+
57+
```python
58+
"""
59+
This function sums a and b
60+
"""
61+
def sum(a, b):
62+
return a + b
63+
```
64+
65+
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:
66+
67+
```python
68+
def sumab(a, b):
69+
"""
70+
This function sums two integers a and b
71+
Return: a + b
72+
"""
73+
return a + b
74+
```
75+
76+
- `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.
77+
78+
- This is arguable: **write comments** and assign appropriate variable names, so that the code is easy to read!
79+
80+
- Write tests to illustrate your work.
81+
82+
The following "testing" approaches are **not** encouraged:
83+
84+
```python
85+
input('Enter your input:')
86+
# Or even worse...
87+
input = eval(input("Enter your input: "))
88+
```
89+
90+
However, if your code uses __input()__ then we encourage you to gracefully deal with leading and trailing whitespace in user input by adding __.strip()__ to the end as in:
91+
92+
```python
93+
starting_value = int(input("Please enter a starting value: ").strip())
94+
```
95+
96+
Please write down your test case, like the following:
97+
98+
```python
99+
def sumab(a, b):
100+
return a + b
101+
# Write tests this way:
102+
print(sumab(1, 2)) # 1+2 = 3
103+
print(sumab(6, 4)) # 6+4 = 10
104+
# Or this way:
105+
print("1 + 2 = ", sumab(1, 2)) # 1+2 = 3
106+
print("6 + 4 = ", sumab(6, 4)) # 6+4 = 10
107+
```
108+
109+
Better yet, if you know how to write [__doctests__](https://docs.python.org/3/library/doctest.html), please consider adding them.
110+
111+
- Avoid importing external libraries for basic algorithms. Only use those libraries for complicated algorithms.
112+
113+
#### Other Standard While Submitting Your Work
114+
115+
- File extension for code should be `.py`. Jupiter notebook files are acceptable in machine learning algorithms.
116+
117+
- Strictly use snake case (underscore separated) in your file name, as it will be easy to parse in future using scripts.
118+
119+
If possible, follow the standard *within* the folder you are submitting to.
120+
121+
- If you have modified/added code work, make sure the code compiles before submitting.
122+
123+
- If you have modified/added documentation work, ensure your language is concise and contains no grammar errors.
124+
125+
- Do not update the README.md or DIRECTORY.md file which will be periodically autogenerated by our Travis CI processes.
126+
127+
- Add a corresponding explanation to [Algorithms-Explanation](https://github.com/TheAlgorithms/Algorithms-Explanation) (Optional but recommended).
128+
129+
- 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.
130+
131+
- Most importantly,
132+
133+
- **Be consistent in the use of these guidelines when submitting.**
134+
- **Join** [Gitter](https://gitter.im/TheAlgorithms) **now!**
135+
- Happy coding!
136+
137+
138+
139+
Writer [@poyea](https://github.com/poyea), Jun 2019.

0 commit comments

Comments
 (0)