Skip to content

Instantly share code, notes, and snippets.

@sorsaffari
Last active March 7, 2019 00:50
Show Gist options
  • Save sorsaffari/15c6280afc0d65496532108677971c86 to your computer and use it in GitHub Desktop.
Save sorsaffari/15c6280afc0d65496532108677971c86 to your computer and use it in GitHub Desktop.
def win(clouds):
print(clouds)
now_on = -1
jumps = 0
if clouds[-1] == 1:
print("invalid game! ends with a thunderhead.")
return None
while True:
if now_on == len(clouds) - 1:
print("won with " + str(jumps) + " jumps")
break
answer = clouds[now_on + 1] + clouds[now_on + 2] + clouds[now_on + 1]
if answer == 3:
print("invalid game. I see no cumulus.")
break
if answer == 1:
now_on += 1
elif answer == 2 or answer == 0:
now_on += 2
jumps += 1
win([0, 0, 0, 0, 1, 0])
win([0, 1, 0, 0, 1, 0])
win([1, 0, 0, 1, 0, 1])
win([1, 0, 1, 1, 0, 0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment