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 5:27


when will u python fags learn that javascript is superior?



function win_odds(a,b,c,d){var ab=a+b,cd=c+d,result='ABCD'; if(ab%2==1&&cd%2==0)result='AB'; if(ab%2==0&&cd%2==1)result='CD'; if(ab%2==1&&cd%2==1){if(ab==cd){var ab_odd=a%2==0?b:a, cd_odd=c%2==0?d:c; if(ab_odd!=cd_odd){result=ab_odd>cd_odd?'AB':'CD';}}else{result=ab>cd?'AB':'CD';}}else if(ab%2==0&&cd%2==0){if(ab<=6&&cd<=6){if(ab==6&&cd!=6)result='AB';else if(ab!=6&&cd==6)result='CD';}else if(ab>6&&cd>6){if(ab!=cd){if(ab==10||cd==10){result=ab==10?'AB':'CD';}else if(ab==12||cd==12){result=ab==12?'AB':'CD';}}}} return result;}

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