Skip to content

Instantly share code, notes, and snippets.

@st0le
Created May 11, 2013 05:03
Show Gist options
  • Save st0le/5558962 to your computer and use it in GitHub Desktop.
Save st0le/5558962 to your computer and use it in GitHub Desktop.
Naive Rotation Point
import random
L = 10
lst = [random.randint(0,100) for _ in xrange(L)]
lst.sort()
K = random.randint(0,L)
lst = lst[K:] + lst[:K] # rotate by random K
def find_rotation_naive(L):
for i in xrange(len(L) - 1):
if L[i] > L[i+1]:
return i + 1
return 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment