Update solution_01.py

format
This commit is contained in:
2022WPJ 2022-10-07 16:40:51 +08:00 committed by GitHub
parent 3b8781da03
commit 69741bc6f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,6 +2,10 @@ import random
def quicksort(nums, left=None, right=None):
if left is None:
left = 0
if right is None:
right = len(nums) - 1
if right <= left:
return
j = left
@ -16,6 +20,10 @@ def quicksort(nums, left=None, right=None):
return nums
def main():
nums = random.sample(range(100000), 100000)
assert sorted(nums) == quicksort(nums)
if __name__ == '__main__':
nums = [random.randint(1, 100000) for _ in range(10000)]
assert sorted(nums) == quicksort(nums, 0, len(nums)-1)
main()