Skip to content

Instantly share code, notes, and snippets.

@Praseetha-KR
Last active August 29, 2015 14:14
Show Gist options
  • Save Praseetha-KR/58c827a48efb927e5806 to your computer and use it in GitHub Desktop.
Save Praseetha-KR/58c827a48efb927e5806 to your computer and use it in GitHub Desktop.
a = {}
def hot_cold(n, m):
if (n > m):
n, m = m, n
if a.has_key((n,m)):
return a[(n,m)]
else:
if ((n, m) == (0, 0)):
return False
else:
for k in range(1, n + 1):
if not hot_cold(n - k, m):
a.[(n - k, m)] = True
return True
for k in range(1, m + 1):
if not hot_cold(n, m - k):
a.[(n, m - k)] = True
return True
for k in range(1, (min(n, m) + 1)):
if not hot_cold(n - k, m - k):
a.[(n - k, m - k)] = True
return True
a[(n, m)] = False
return False
if __name__ == "__main__":
t = int(raw_input());
for i in range(t):
n = map(int, raw_input().split(" "))
if hot_cold(n[0], n[1]):
print "Play"
else:
print "Don't Play"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment