Skip to content
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

adding doctests for radix_sort.py #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Sorting/Radix_Sort.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@
# digits of same place value. Then, sort the elements
# according to their increasing/decreasing order.

"""
For doctests run following command:
python -m doctest -v Radix_Sort.py
or
python3 -m doctest -v Radix_Sort.py
For manual testing run:
python Radix_Sort.py
"""

from math import log10
from random import randint

Expand All @@ -17,6 +26,11 @@ def prefix_sum(array):
return array

def radixsort(l, base=10):
"""
Examples:
>>> radixsort([0, 5, 3, 2, 2])
[0, 2, 2, 3, 5]
"""
passes = int(log10(max(l))+1)
output = [0] * len(l)

Expand Down