1
+ <<< Python Changed names of variables
2
+
3
+ MAX_SIZE = 100
4
+
5
+ class Mapping:
6
+ def __init__(self, iterable):
7
+ self.items_list = []
8
+ self.__update(iterable)
9
+
10
+ def update(self, iterable):
11
+ for item in iterable:
12
+ self.items_list.append(item)
13
+
14
+ __update = update # private copy of original update() method
15
+
16
+
17
+ class MappingSubclass(Mapping):
18
+
19
+ def update(self, keys, values):
20
+ # provides new signature for update()
21
+ # but does not break __init__()
22
+ for item in zip(keys, values):
23
+ self.items_list.append(item)
24
+
25
+ def quickSort(alist):
26
+ quickSortHelper(alist,0,len(alist)-1)
27
+
28
+ def quickSortHelper(alist,first,last):
29
+ if first<last:
30
+
31
+ splitpoint = partition(alist,first,last)
32
+
33
+ quickSortHelper(alist,first,splitpoint-1)
34
+ quickSortHelper(alist,splitpoint+1,last)
35
+
36
+
37
+ def partition(alist,first,last):
38
+ pivotvalue = alist[first]
39
+
40
+ leftmark = first+1
41
+ rightmark = last
42
+
43
+ done = False
44
+ while not done:
45
+
46
+ while leftmark <= rightmark and \
47
+ alist[leftmark] <= pivotvalue:
48
+ leftmark = leftmark + 1
49
+
50
+ while alist[rightmark] >= pivotvalue and \
51
+ rightmark >= leftmark:
52
+ rightmark = rightmark -1
53
+
54
+ if rightmark < leftmark:
55
+ done = True
56
+ else:
57
+ temp = alist[leftmark]
58
+ alist[leftmark] = alist[rightmark]
59
+ alist[rightmark] = temp
60
+
61
+ temp = alist[first]
62
+ alist[first] = alist[rightmark]
63
+ alist[rightmark] = temp
64
+
65
+
66
+ return rightmark
67
+
68
+ =====
69
+
70
+ SIZE = 100
71
+
72
+ class Map:
73
+ def __init__(self, iter):
74
+ self.i_list = []
75
+ self.__upd(iterable)
76
+
77
+ def upd(self, iterat):
78
+ for item in iterat:
79
+ self.i_list.append(item)
80
+
81
+ __upd = upd # private copy of original update() method
82
+
83
+ class MapSub(Map):
84
+
85
+ def upd(self, keys, values):
86
+ # provides new signature for update()
87
+ # but does not break __init__()
88
+ for item in zip(keys, values):
89
+ self.items_list.append(item)
90
+
91
+ def qS(mylst):
92
+ qSH(mylst,0,len(mylst)-1)
93
+
94
+ def qSH(mylst,start,end):
95
+ if start<end:
96
+
97
+ centersplit = Myfunc(mylst,start,end)
98
+
99
+ qSH(mylst,start,centersplit-1)
100
+ qSH(mylst,centersplit+1,end)
101
+
102
+
103
+ def Myfunc(mylist,start,finish):
104
+ tempvalue = mylist[start]
105
+
106
+ left = start+1
107
+ right = finish
108
+
109
+ done = False
110
+ while not done:
111
+
112
+ while left <= right and \
113
+ mylist[left] <= tempvalue:
114
+ left = left + 1
115
+
116
+ while mylist[right] >= tempvalue and \
117
+ right >= left:
118
+ right = right -1
119
+ if right < left:
120
+ done = True
121
+ else:
122
+ temp = mylist[left]
123
+ mylist[left] = mylist[right]
124
+ mylist[right] = temp
125
+
126
+ temp = mylist[start]
127
+ mylist[start] = mylist[right]
128
+ mylist[right] = temp
129
+
130
+
131
+ return right
0 commit comments