Skip to content

Instantly share code, notes, and snippets.

@richvincent
Created December 24, 2015 15:53
Show Gist options
  • Save richvincent/6cab89a4d5ff141addfd to your computer and use it in GitHub Desktop.
Save richvincent/6cab89a4d5ff141addfd to your computer and use it in GitHub Desktop.
def answer(numbers):
if isinstance(numbers, list):
loop = list(set(numbers))
if len(loop) < 5000:
if len(loop) > 2:
if loop[0] == 0:
return len(loop) - 1
elif len(loop) == 2:
return 2
else:
raise ValueError('Please no less than 2 and\
no more than 5000 pirates')
else:
raise ValueError('Please supply a list')
assert (answer([1, 3, 0, 1]) == 2)
assert (answer([1, 0]) == 2)
assert (answer([1, 2, 1]) == 2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment