psf/black code formatting (#1277)

This commit is contained in:
William Zhang
2019-10-05 01:14:13 -04:00
committed by Christian Clauss
parent 07f04a2e55
commit 9eac17a408
291 changed files with 6014 additions and 4571 deletions

View File

@ -1,4 +1,4 @@
'''
"""
This is a pure python implementation of the heap sort algorithm.
For doctests run following command:
@ -8,7 +8,8 @@ python3 -m doctest -v heap_sort.py
For manual testing run:
python heap_sort.py
'''
"""
def heapify(unsorted, index, heap_size):
largest = index
@ -26,7 +27,7 @@ def heapify(unsorted, index, heap_size):
def heap_sort(unsorted):
'''
"""
Pure implementation of the heap sort algorithm in Python
:param collection: some mutable ordered collection with heterogeneous
comparable items inside
@ -41,7 +42,7 @@ def heap_sort(unsorted):
>>> heap_sort([-2, -5, -45])
[-45, -5, -2]
'''
"""
n = len(unsorted)
for i in range(n // 2 - 1, -1, -1):
heapify(unsorted, i, n)
@ -50,7 +51,8 @@ def heap_sort(unsorted):
heapify(unsorted, 0, i)
return unsorted
if __name__ == '__main__':
user_input = input('Enter numbers separated by a comma:\n').strip()
unsorted = [int(item) for item in user_input.split(',')]
if __name__ == "__main__":
user_input = input("Enter numbers separated by a comma:\n").strip()
unsorted = [int(item) for item in user_input.split(",")]
print(heap_sort(unsorted))