forked from jwasham/practice-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
65 lines (44 loc) · 1.26 KB
/
main.py
File metadata and controls
65 lines (44 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
from quick_sort import QuickSort
def is_sorted(numbers):
last_num = float("-inf")
for num in numbers:
if num < last_num:
return False
else:
last_num = num
return True
def check_sort(original):
numbers = original[:]
qs = QuickSort(numbers)
output = qs.sort()
print(output)
if is_sorted(output):
print("** SUCCESS! **")
else:
print("Uh oh - not in order.")
if contain_same_ints(original, numbers):
print("** Contain the same elements! **")
else:
print("Uh oh - something is missing.")
print("---")
def contain_same_ints(arr1, arr2):
for i in arr1:
found = False
for j in arr2:
if i == j:
found = True
if not found:
return False
return True
def main():
check_sort([325432, 989, 547510, 3, -93, 189019, 5042, 123,
597, 42, 7506, 184, 184, 2409, 45, 824,
4, -2650, 9, 662, 3928, -170, 45358, 395,
842, 7697, 110, 14, 99, 221])
check_sort([9, 9, 9, 9, 9, 9, 9, 9, 9, 9])
check_sort([3, 5, 7, 9, 23, 25, 34, 53, 77, 199])
check_sort([3, 5, 7])
check_sort([3, 5])
check_sort([3])
if __name__ == "__main__":
main()