PROBLEM LINK:
THEDICEGAME | CodeChef
Author: Charan Narukulla
DIFFICULTY:
CAKEWALK
PREREQUISITES:
math
PROBLEM:
Madhu and Prithvi are two friends. They started playing a dice game. It’s Madhu’s turn. Given nn the number of times dice thrown by both the persons subsequently one after the another. The person should reduce nn with the number obtained and update nn. Given the number obtained at each turn. The first person who gets a negative number will loose and other will win. Print the name of winner in lower case.
EXPLANATION:
After taking each value of input dice value , reduce the the N value. For a particular turn the person who makes N negative will loose the game.
SOLUTIONS:
Tester's Solution
try:
n=int(input())
c=0
o=n
for i in range(n):
k=int(input())
n=n-k
c=c+1
if n<0 and c%2==0:
print('madhu')
break
if n<0 and c%2!=0:
print('prithvi')
break
if c==o and n>0:
print('0')
#break
except:
pass