Skip to content

Commit cf903ce

Browse files
authored
Merge pull request #1 from TheAlgorithms/master
update branch
2 parents c1e6955 + 01601e6 commit cf903ce

File tree

424 files changed

+271380
-386
lines changed

Some content is hidden

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

424 files changed

+271380
-386
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']

.github/stale.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Number of days of inactivity before an issue becomes stale
2+
daysUntilStale: 30
3+
# Number of days of inactivity before a stale issue is closed
4+
daysUntilClose: 7
5+
# Issues with these labels will never be considered stale
6+
exemptLabels:
7+
- bug
8+
- help wanted
9+
- OK to merge
10+
# Label to use when marking an issue as stale
11+
staleLabel: wontfix
12+
# Comment to post when marking an issue as stale. Set to `false` to disable
13+
markComment: >
14+
This issue has been automatically marked as stale because it has not had
15+
recent activity. It will be closed if no further activity occurs. Thank you
16+
for your contributions.
17+
# Comment to post when closing a stale issue. Set to `false` to disable
18+
closeComment: true

.gitignore

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ __pycache__/
88

99
# Distribution / packaging
1010
.Python
11-
env/
1211
build/
1312
develop-eggs/
1413
dist/
@@ -20,9 +19,11 @@ lib64/
2019
parts/
2120
sdist/
2221
var/
22+
wheels/
2323
*.egg-info/
2424
.installed.cfg
2525
*.egg
26+
MANIFEST
2627

2728
# PyInstaller
2829
# Usually these files are written by a python script from a template
@@ -42,8 +43,9 @@ htmlcov/
4243
.cache
4344
nosetests.xml
4445
coverage.xml
45-
*,cover
46+
*.cover
4647
.hypothesis/
48+
.pytest_cache/
4749

4850
# Translations
4951
*.mo
@@ -52,6 +54,7 @@ coverage.xml
5254
# Django stuff:
5355
*.log
5456
local_settings.py
57+
db.sqlite3
5558

5659
# Flask stuff:
5760
instance/
@@ -66,7 +69,7 @@ docs/_build/
6669
# PyBuilder
6770
target/
6871

69-
# IPython Notebook
72+
# Jupyter Notebook
7073
.ipynb_checkpoints
7174

7275
# pyenv
@@ -75,16 +78,32 @@ target/
7578
# celery beat schedule file
7679
celerybeat-schedule
7780

78-
# dotenv
79-
.env
81+
# SageMath parsed files
82+
*.sage.py
8083

81-
# virtualenv
84+
# Environments
85+
.env
86+
.venv
87+
env/
8288
venv/
8389
ENV/
90+
env.bak/
91+
venv.bak/
8492

8593
# Spyder project settings
8694
.spyderproject
95+
.spyproject
8796

8897
# Rope project settings
8998
.ropeproject
99+
100+
# mkdocs documentation
101+
/site
102+
103+
# mypy
104+
.mypy_cache/
105+
106+
.DS_Store
90107
.idea
108+
.try
109+
.vscode/

.travis.yml

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
language: python
2-
python:
3-
- "3.2"
4-
- "3.3"
5-
- "3.4"
6-
- "3.5"
7-
install:
8-
- if [ "$TRAVIS_PYTHON_VERSION" == "3.2" ]; then travis_retry pip install coverage==3.7.1; fi
9-
- if [ "$TRAVIS_PYTHON_VERSION" != "3.2" ]; then travis_retry pip install coverage; fi
10-
- "pip install pytest pytest-cov"
11-
script: py.test --doctest-modules --cov ./
2+
dist: xenial # required for Python >= 3.7
3+
python: 3.7
4+
cache: pip
5+
before_install: pip install --upgrade pip setuptools
6+
install: pip install -r requirements.txt
7+
before_script:
8+
- black --check . || true
9+
- flake8 . --count --select=E9,F4,F63,F7,F82 --show-source --statistics
10+
script:
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

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)