Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

How do you do this? (Python)

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:


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”

Name: Anonymous 2013-02-23 6:37

>>15
first of all, you turned some solid, thick, tight javascript into some ugly forced-indentation python. fuck that gay language

second, look at your return values for the lower spaghetti logic. when you assign "ab_odd > cd_odd" to the variable 'return', what the fuck are you getting back from your function? i don't know how python represents true/false values when you assign them to variables, but regardless of what it sends back it's not going to be 'AB' or 'CD' is it?

since python blows and doesn't have the ?: operator, you need to convert that too: http://stackoverflow.com/questions/2191890/conditional-operator-in-python

welp, i'm done doing your homework. you're welcome

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List