From 4b67591e65d9c3fd9f883dc804a38468a404b11e Mon Sep 17 00:00:00 2001 From: mahema-14 Date: Wed, 25 Mar 2026 19:49:59 +0530 Subject: [PATCH 1/5] 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/5] [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__": From 7268d287290d70deadfce2cb69045daacb1c8b43 Mon Sep 17 00:00:00 2001 From: Maxim Smolskiy Date: Sat, 11 Apr 2026 00:34:04 +0300 Subject: [PATCH 3/5] Update pigeonhole_sort.py --- sorts/pigeonhole_sort.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sorts/pigeonhole_sort.py b/sorts/pigeonhole_sort.py index 4d117f339cb6..11ffb6057ad6 100644 --- a/sorts/pigeonhole_sort.py +++ b/sorts/pigeonhole_sort.py @@ -10,9 +10,11 @@ def pigeonhole_sort(a): >>> pigeonhole_sort(a) # a destructive sort >>> a == b True + + >>> pigeonhole_sort([]) """ - 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 From 7456a84856e7122c89b3bc6ba2fb346405e726f1 Mon Sep 17 00:00:00 2001 From: Maxim Smolskiy Date: Sat, 11 Apr 2026 00:41:37 +0300 Subject: [PATCH 4/5] Update pigeonhole_sort.py --- sorts/pigeonhole_sort.py | 1 + 1 file changed, 1 insertion(+) diff --git a/sorts/pigeonhole_sort.py b/sorts/pigeonhole_sort.py index 11ffb6057ad6..e763e5f61571 100644 --- a/sorts/pigeonhole_sort.py +++ b/sorts/pigeonhole_sort.py @@ -12,6 +12,7 @@ def pigeonhole_sort(a): True >>> pigeonhole_sort([]) + None """ # if not a: # return # this handles empty list From f605cfadf7872a9ff942df5cd141b6c4b9dd0924 Mon Sep 17 00:00:00 2001 From: Maxim Smolskiy Date: Sat, 11 Apr 2026 00:48:15 +0300 Subject: [PATCH 5/5] Update pigeonhole_sort.py --- sorts/pigeonhole_sort.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sorts/pigeonhole_sort.py b/sorts/pigeonhole_sort.py index e763e5f61571..7fbc6188cfb4 100644 --- a/sorts/pigeonhole_sort.py +++ b/sorts/pigeonhole_sort.py @@ -12,10 +12,9 @@ def pigeonhole_sort(a): True >>> pigeonhole_sort([]) - None """ - # if not a: - # return # this handles empty list + if not a: + return # size of range of values in the list (ie, number of pigeonholes we need) min_val = min(a) # min() finds the minimum value @@ -43,7 +42,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:", *a) if __name__ == "__main__":