Created
May 19, 2018 04:10
-
-
Save fbparis/be524bdb63204ef2b5e524cf90a20129 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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