-
-
Save richvincent/6cab89a4d5ff141addfd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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