From 30d8490fb1da022880686d72dee629c23766302f Mon Sep 17 00:00:00 2001 From: K Meenakshi <40635770+meenakshi777@users.noreply.github.com> Date: Mon, 29 Oct 2018 23:33:30 +0530 Subject: [PATCH] Update 100+ Python challenging programming exercises.txt --- ...Python challenging programming exercises.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/100+ Python challenging programming exercises.txt b/100+ Python challenging programming exercises.txt index 97af5aaf..9d75fac8 100644 --- a/100+ Python challenging programming exercises.txt +++ b/100+ Python challenging programming exercises.txt @@ -2371,5 +2371,22 @@ solutions=solve(numheads,numlegs) print solutions #----------------------------------------# +Question: + +In a regular table tennis match, the player who serves changes every time after 2 points are scored, regardless of which players scored them. + +Chef and Cook are playing a different match — they decided that the player who serves would change every time after K points are scored instead (again regardless of which players scored them). When the game starts, it's Chef's turn to serve. + +You are given the current number of points scored by Chef and Cook (P1 and P2 respectively). Find out whether Chef or Cook has to serve next. + +Solution: + +n=int(input()) +for i in range(n): + a=list(map(int,input().split())) + if(((a[0]+a[1])//a[2])%2==0): + print('CHEF') + else: + print('COOK')