id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

nontransitive_dice


Regular dice have the numbers 1 through 6 on the 6 sides. But consider dice that might have other numbers on the sides. For example, a die with the numbers "777777" on the six sides. This would beat a regular die, "123456", every time, no matter what side comes up on either dice. We say that a die A beats a die B if out of all the possible combinations of sides of A and sides of B, the A side is greater than the B side more than half the time. For example, A = "234567" beats B = "123456" because, out of the 6 * 6 = 36 combinations, A wins 21, loses 10, and ties 5. Interestingly, there exist sets of dice {A,B,C} such that A beats B, B beats C, and C beats A. These are called "nontransitive dice". Write the function nontransitive_dice(A, B, C) which returns True if {A, B, C} is a set of nontransitive dice. (This function only needs to handle exactly three dice, but make sure you allow for those gamers who have dice with 12 or 20 or any other number of sides.)


nontransitive_dice('113556', '233445', '122446') → True
nontransitive_dice('123456', '233445', '122446') → True
nontransitive_dice('654321', '123456', '333444') → False

...Save, Compile, Run (ctrl-enter)

def nontransitive_dice(A, B, C):

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Python Help

Difficulty: 301 Post-solution available

Copyright Nick Parlante 2017 - privacy