Skip to content

Commit fc2f947

Browse files
mahema-14pre-commit-ci[bot]MaximSmolskiy
authored
Fix empty input edge case and correct output formatting (#14444)
* Fix empty input edge case and correct output formatting * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update pigeonhole_sort.py * Update pigeonhole_sort.py * Update pigeonhole_sort.py --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
1 parent f944b91 commit fc2f947

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

sorts/pigeonhole_sort.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ def pigeonhole_sort(a):
1010
>>> pigeonhole_sort(a) # a destructive sort
1111
>>> a == b
1212
True
13+
14+
>>> pigeonhole_sort([])
1315
"""
16+
if not a:
17+
return
1418
# size of range of values in the list (ie, number of pigeonholes we need)
1519

1620
min_val = min(a) # min() finds the minimum value
@@ -38,7 +42,7 @@ def pigeonhole_sort(a):
3842
def main():
3943
a = [8, 3, 2, 7, 4, 6, 8]
4044
pigeonhole_sort(a)
41-
print("Sorted order is:", " ".join(a))
45+
print("Sorted order is:", *a)
4246

4347

4448
if __name__ == "__main__":

0 commit comments

Comments
 (0)