Seven Game X80093


Statement
 

pdf   zip

html

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 p and q got by the first player and r and s got by the second player returns integer 1 if the winner is the first player, returns 2 when the winner is the second player and returns integer 0 when there is no winner. Dice values p, q, r and s are integers greater than zero and less that seven

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