Name: Anonymous 2013-02-23 3:51
Consider a dice battle game called What-Are-the-Odds? It is a team battle game where team_ab plays against
team_cd and two players are on a team. Each player rolls a die and adds their roll value to their teammate’s
value. The first team_ab, will roll values represented by a and b. The second team_cd, will roll values
represented by c and d. Let the sum of the dice values for team_ab be represented by AB, and the sum of the dice
values for team_cd be represented by CD.
Rules of battle are as follows and apply to either team.
Die values will be integers from 1 to 6, inclusive
If only one of AB and CD are odd: The team with the odd number wins.
If AB and CD are both odd: The largest odd number wins. If there is a tie, the individual rolls of a, b, c,
and d must be examined. The team with the largest odd number roll wins.
If exactly one of AB or CD is an even number <= 6: The team with the even number loses.
If AB and CD are both even and <=6: The team with AB or CD that is divisible by the largest odd
number wins.
If AB and CD are both even and >6: The team with AB or CD that is divisible by the largest odd number
wins.
A tie will occur in all situations in which a winner is not determined.
Write a python function, win_odds, that consumes 4 dice values, a, b, c, or d (integers 1-6), and produces
the winning team represented by a string (“AB”, “CD”, or “ABCD” when there is a tie). Some examples follow:
team_cd and two players are on a team. Each player rolls a die and adds their roll value to their teammate’s
value. The first team_ab, will roll values represented by a and b. The second team_cd, will roll values
represented by c and d. Let the sum of the dice values for team_ab be represented by AB, and the sum of the dice
values for team_cd be represented by CD.
Rules of battle are as follows and apply to either team.
Die values will be integers from 1 to 6, inclusive
If only one of AB and CD are odd: The team with the odd number wins.
If AB and CD are both odd: The largest odd number wins. If there is a tie, the individual rolls of a, b, c,
and d must be examined. The team with the largest odd number roll wins.
If exactly one of AB or CD is an even number <= 6: The team with the even number loses.
If AB and CD are both even and <=6: The team with AB or CD that is divisible by the largest odd
number wins.
If AB and CD are both even and >6: The team with AB or CD that is divisible by the largest odd number
wins.
A tie will occur in all situations in which a winner is not determined.
Write a python function, win_odds, that consumes 4 dice values, a, b, c, or d (integers 1-6), and produces
the winning team represented by a string (“AB”, “CD”, or “ABCD” when there is a tie). Some examples follow:
win_odds(2, 3, 6, 6) => “AB”
win_odds(2, 3, 5, 6) => “CD”
win_odds(2, 2, 1, 3) => “ABCD”
win_odds(1, 1, 1, 2) => “CD”
win_odds(3, 5, 5, 5) => “CD”
win_odds(2, 4, 2, 2) => “AB”
win_odds(1, 5, 1, 3) => “AB”
win_odds(6, 6, 4, 4) => “AB”