Last active
January 22, 2017 14:34
-
-
Save 0xcrypto/99a81d3336e6046292ff 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
#!/usr/bin/env python | |
"""Usage: devil.devilgame(N, (F,B,T,FD,BD)) | |
Expects 2 arguments. First is integer while second is a tuple. | |
""" | |
def devilgame(N, (F, B, T, FD, BD)): | |
# initializing variables | |
piratesPos = 0 | |
meters = 0 | |
returnStr = ["", ""] | |
def check(): | |
# checks if piratesPos matches BD or FD returns accordingly | |
if(piratesPos == BD): | |
returnStr[0] = "Time Taken: ", meters*T | |
returnStr[1] = "B: ", B | |
return True | |
if(piratesPos == FD): | |
returnStr[0] = "Time Taken: ", meters*T | |
returnStr[1] = "F: ", F | |
return True | |
return False | |
for x in range(N-1): | |
piratesPos = piratesPos - B | |
meters = meters+B | |
if(check()): | |
break | |
piratesPos = piratesPos + F | |
meters = meters+F | |
if(check()): | |
break | |
if(returnStr[0] == ""): print "Thank God" | |
else: | |
print returnStr[0] | |
print returnStr[1] | |
return returnStr | |
if(__name__ == '__main__'): | |
N = int(raw_input("N (integer only): ")) | |
tup = raw_input("F B T FD BD (integer only): ") | |
tup = tup.split(" ") | |
tupl = [] | |
for x in tup: | |
tupl.append(int(x)) | |
tup = tuple(tupl) | |
devilgame(N,tup) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment