def lowest_index(rl, start=0): mid = len(rl)/2 if rl[mid] < rl[mid-1]: return mid+start if rl[mid] > rl[mid+1]: return mid+1+start if rl[0] > rl[mid]: return lowest_index(rl[0:mid]) if rl[mid] > rl[-1]: return lowest_index(rl[mid:-1], start=mid) return 'List is not integers or is not rotated' print lowest_index([7, 8, 9, 1, 2, 3, 4, 5, 6]) print lowest_index([4, 5, 6, 7, 8, 9, 1, 2, 3,]) print lowest_index([1, 2, 3, 4, 5, 6, 7, 8, 9]) print lowest_index('abced')
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question