Seven Game X80093


Statement
 

pdf   zip

Two players play the Seven game. Each one throws a pair of dice on the table and scores the sum of the obtained values. A player wins when his score does not exceed seven and it is either closer to seven than the rival’s score or the rival’s score exceeds seven. Note that there are cases where no player wins. Write a function @winner(p, q, r, s)@ that given the dice values pp and qq got by the first player and rr and ss got by the second player returns integer 11 if the winner is the first player, returns 22 when the winner is the second player and returns integer 00 when there is no winner. Dice values p,q,rp, q, r and ss are integers greater than zero and less that seven

Sample session

Sample session
>>> winner(1, 3, 5, 3)
1
>>> winner(2, 4, 4, 3)
2
>>> winner(1, 3, 2, 3)
2
>>> winner(2, 4, 3, 3)
0
>>> winner(4, 4, 5, 6)
0
Information
Author
ProAl
Language
English
Official solutions
Python
User solutions
Python