Skip to content

Instantly share code, notes, and snippets.

@fbparis
Created May 19, 2018 04:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fbparis/be524bdb63204ef2b5e524cf90a20129 to your computer and use it in GitHub Desktop.
Save fbparis/be524bdb63204ef2b5e524cf90a20129 to your computer and use it in GitHub Desktop.
import random
s, z, n = 0, 0, 0
dx, dy = 0, -1
# Let keep it simple :-)
frog = random.randint(-100, 100)
jump = random.randint(-100, 100)
while 1:
i = s + n * z
n += 1
print "turn %d: shoot on %d (s=%d, z=%d)" % (n, i, s, z)
if i == frog:
break
frog += jump
if (s == z) or (s < 0 and s == -z) or (s > 0 and s == 1-z):
dx, dy = -dy, dx
s, z = s + dx, z + dy
print "BANG THE FROG!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment