Fix bugs and add related tests (#2375)

This commit is contained in:
小么小儿郎EL 2020-09-01 00:55:56 +08:00 committed by GitHub
parent 472f63eaa5
commit 80daa5750a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,11 +7,13 @@ def radix_sort(list_of_ints: List[int]) -> List[int]:
True True
radix_sort(reversed(range(15))) == sorted(range(15)) radix_sort(reversed(range(15))) == sorted(range(15))
True True
radix_sort([1,100,10,1000]) == sorted([1,100,10,1000])
True
""" """
RADIX = 10 RADIX = 10
placement = 1 placement = 1
max_digit = max(list_of_ints) max_digit = max(list_of_ints)
while placement < max_digit: while placement <= max_digit:
# declare and initialize empty buckets # declare and initialize empty buckets
buckets = [list() for _ in range(RADIX)] buckets = [list() for _ in range(RADIX)]
# split list_of_ints between the buckets # split list_of_ints between the buckets