5 kyu

Equivalent Dice

106 of 148raulbc777
Description
Loading description...
Algorithms
Performance
Number Theory
Recursion
Fundamentals
View
AllIssues3Questions3Suggestions3Show Resolved
  • Please sign in or sign up to leave a comment.
  • nollanr1 Avatar

    This comment has been hidden.

  • saudiGuy Avatar
  • Len512 Avatar

    Has anyone solved this in Javascript lately?

    I keep failing 5-6 random tests, even though I produce the same result as in the Python version (which passes all tests)

    For input: [ 11, 11, 4, 12, 11, 5, 4 ], Python produces 15 but the JS version requires 16.

    For input: [ 9, 8, 7, 11, 5, 6, 7 ], Python produces 58 but the JS version requires 72.

    Are there problems in the JS version, or are the tests in Python somewhat lax?

  • hksong Avatar

    Two of the "random" test cases are wrong.

    Log
    input:[5,4]    events:20
    sets:[[4,5]]
    output:0
    Expected: 1, instead got: 0
    
    Log
    input:[4,5]    events:20
    sets:[[4,5]]
    output:0
    Expected: 1, instead got: 0
    

    It works for smaller cases and larger cases. I think it only breaks on 20.

    Log
    input:[3,3]    events:9
    sets:[[3,3]]
    output:0
    Test Passed: Value == 0
    
    Log
    input:[7,3]    events:21
    sets:[[3,7]]
    output:0
    
  • eds8531 Avatar

    Am I missing something? The test cases list [3, 3] as having no equivalent dice paterns, but wouldn't [9] also have 9 outcomes?

  • JohanWiltink Avatar
  • JohanWiltink Avatar

    ( JS )

    From a random test: eqDice( [ 4, 4, 5, 5 ] ) => 5

    But I can only find equivalent sets [ 4, 5, 20 ], [ 4, 10, 10 ], [ 5, 5, 16 ], [ 5, 8, 10 ] ]. What is the fifth?

    I have the same problem with eqDice([3,8,15,20]) => 44 from the basic tests, where I can only find 42, but that's a bit unwieldy to post.

    The set itself is not supposed to count as an equivalent set, right?

  • obaqueiro_ Avatar

    I am running the Ruby version of this and I think there might be an issue with a test. My code passes all test except the [4,5] one. Which says "excepted 1 got 0):

    Log {"4,5"=>1} Expected: 1, instead got: 0

    However, we are talking about 20 as the value to arrive to... and according to a different test, [20] there should be only 1 combination: [4,5].
    So following the logic of other tests: Total Combinations - Original Combination (IF it is valid, as [20] is not valid). [4,5] should be 0 and not 1.

  • JohanWiltink Avatar

    dice have a minimum of three sides

    You've never flipped a coin ?!?

    I've done that a lot more than roll my d4 with one empty side ( which I don't have - I'd use a d6 div 2 or mod 3 ( and if I get away with it, I decide afterwards :) ).

  • Hugo0 Avatar

    The test cases could use some more examples.

  • Blind4Basics Avatar

    There is A LOT of variation in the performances requirmement from on batch to the other. My solution (forked one) can take from 0,9s to 10s to pass the tests... :/

  • ZED.CWT Avatar

    In random tests. Why you put .it under .assert_equals?