-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcount_rotation.py
26 lines (26 loc) · 1.47 KB
/
count_rotation.py
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
def findMin( A):
low = 0
high = len(A)-1
N = len(A)
while low <= high:
# print low,high
# if A[low] <= A[high]:
# return A[low]
mid = (low+high)/2
print low,high,mid
print A[low], A[mid], A[high]
nex = (mid+1)%N
prev = (mid+N-1)%N
# if A[mid] <= A[prev] and A[mid] <= A[nex]:
# print "not mid"
# return A[mid]
if A[mid] <= A[high]:
print "high reduced"
high = mid-1
elif A[mid] <= A[low]:
print "low increased"
low = mid+1
else:
print "this"
print findMin([40342, 40766, 41307, 42639, 42777, 46079, 47038, 47923, 48064, 48083, 49760, 49871, 51000, 51035, 53186, 53499, 53895, 59118, 60467, 60498, 60764, 65158, 65838, 65885, 65919, 66638, 66807, 66989, 67114, 68119, 68146, 68584, 69494, 70914, 72312, 72432, 74536, 77038, 77720, 78590, 78769, 78894, 80169, 81717, 81760, 82124, 82583, 82620, 82877, 83131, 84932, 85050, 85358, 89896, 90991, 91348, 91376, 92786, 93626, 93688, 94972, 95064, 96240, 96308, 96755, 97197, 97243, 98049, 98407, 98998, 99785, 350, 2563, 3075, 3161, 3519, 4176, 4371, 5885, 6054, 6495, 7218, 7734, 9235, 11899, 13070, 14002, 16258, 16309, 16461, 17338, 19141, 19526, 21256, 21507, 21945, 22753, 25029, 25524, 27311, 27609, 28217, 30854, 32721, 33184, 34190, 35040, 35753, 36144, 37342 ]
)