From 4b67591e65d9c3fd9f883dc804a38468a404b11e Mon Sep 17 00:00:00 2001 From: mahema-14 Date: Wed, 25 Mar 2026 19:49:59 +0530 Subject: [PATCH 1/2] Fix empty input edge case and correct output formatting --- sorts/pigeonhole_sort.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sorts/pigeonhole_sort.py b/sorts/pigeonhole_sort.py index bfa9bb11b8a6..77fc78e276e2 100644 --- a/sorts/pigeonhole_sort.py +++ b/sorts/pigeonhole_sort.py @@ -11,6 +11,8 @@ def pigeonhole_sort(a): >>> a == b True """ + if not a : + return # this handles empty list # size of range of values in the list (ie, number of pigeonholes we need) min_val = min(a) # min() finds the minimum value @@ -38,7 +40,7 @@ def pigeonhole_sort(a): def main(): a = [8, 3, 2, 7, 4, 6, 8] pigeonhole_sort(a) - print("Sorted order is:", " ".join(a)) + print("Sorted order is:", " ".join(map(str,a))) # it converts integer into string if __name__ == "__main__": From 7b231a42720144f4747e487fb3c19975e0e3cffb Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 25 Mar 2026 14:22:27 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- sorts/pigeonhole_sort.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sorts/pigeonhole_sort.py b/sorts/pigeonhole_sort.py index 77fc78e276e2..4d117f339cb6 100644 --- a/sorts/pigeonhole_sort.py +++ b/sorts/pigeonhole_sort.py @@ -11,8 +11,8 @@ def pigeonhole_sort(a): >>> a == b True """ - if not a : - return # this handles empty list + if not a: + return # this handles empty list # size of range of values in the list (ie, number of pigeonholes we need) min_val = min(a) # min() finds the minimum value @@ -40,7 +40,7 @@ def pigeonhole_sort(a): def main(): a = [8, 3, 2, 7, 4, 6, 8] pigeonhole_sort(a) - print("Sorted order is:", " ".join(map(str,a))) # it converts integer into string + print("Sorted order is:", " ".join(map(str, a))) # it converts integer into string if __name__ == "__main__":