Skip to content

Instantly share code, notes, and snippets.

@jweinst1
Created July 11, 2015 08:57
Show Gist options
  • Save jweinst1/3aa843415cd5f7649578 to your computer and use it in GitHub Desktop.
Save jweinst1/3aa843415cd5f7649578 to your computer and use it in GitHub Desktop.
Shortening Search Algorithm.py
def Shortening_search(target):
assert 0<target<1000 #must be between 1 and 999.
list, count = range(1000), 0
while len(list) > 1:
if list[0] == target:
return count
elif list[-1] == target:
return count
else:
list.pop()
list.remove(list[0])
count += 1
return count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment