Ad
  • Default User Avatar

    Sounds similar to the problem below?

  • Default User Avatar

    Great Kata. Tried 4 different methods befoew hitting on a satisfactory solution.

  • Default User Avatar

    I could only get this to work for all attempt by assuming the winners gets 50% or more of the votes, not more than 50%

  • Default User Avatar

    I have a feeling I am missing something in the explantion. All the test cases work fine, but when I run on random inputs I sometimes get failures when replace is False. So let me talk you through my understanding of one test case (w/o showing the code) (... and as you will see I am not a mathematician so I need dummies guide as explantions!)

    The input is [['red', 'yellow', 'red', 'yellow', 'yellow', 'blue', 'red', 'yellow', 'green', 'blue', 'blue', 'green', 'red', 'yellow', 'yellow', 'green', 'yellow', 'blue'], ['blue', 'red'], False]

    So I have 18 balls, 4 of which are blue, so P(b) = 4/18 = 0.222....
    Since I don't replace the blue that I drew on the first round, I now have only 17 balls, 4 of which are red, so P(r) = 4/17 = 0.235...

    So P(b,r,False) = 0.222x0.235 = 0.052, but according to the test, the probablity should be 0.037

    Now - where is the flaw? I was hoping writing this would lead me to enightenment, but not the case this time...

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    I think there is a problem with this kata; getting the examples working is fine but when you randomly get pass and fail on the attempts, there is something wrong.

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution