Answer to Question #307173 in Python for sai

Question #307173

question: Cards Game





There are M people from 1 to M . Andy has N cards with her. Starting with person Z , he gives the cards one by one to the people in the numbering order. Z, Z+1, Z+2,.....,M, 1, 2,....Z-1. Your task is to output the number of the person who will get the last card.





input 1:- 3 3 2



output 1:- 1



input 2 :- 1 100 1



output 2:- 1

1
Expert's answer
2022-03-09T10:24:44-0500
m, n, z = input().split()
m = int(m) # number of peoples
n = int(n) # number of cards
z = int(z) # current person

current = z
while n > 1:
  if current == m:
    current = 1
  else:
    current += 1
  n -= 1
   
print(current)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS