Skip to content

Instantly share code, notes, and snippets.

@DeaconDesperado
Created September 6, 2013 22:39
Show Gist options
  • Save DeaconDesperado/6470955 to your computer and use it in GitHub Desktop.
Save DeaconDesperado/6470955 to your computer and use it in GitHub Desktop.
Circular Arrays
cases = [
([2,2,-1],True),
([3,1,2,-2],True),
([-4,2,4],False),
([9,8,8],False)
]
def is_circular_complete(case):
key = 0
size = len(case)
for index in xrange(size):
nextkey = case[key]
if nextkey > size:
return False
key = (nextkey+key) % size
if key == 0:
return True
return False
for case,should in cases:
assert is_circular_complete(case) == should
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment