Ad
  • Custom User Avatar

    I was able to solve using Math.random and not implementing my own algorithm.

    I don't think this is an expected behaviour, passed using Java.

  • Default User Avatar

    You have to create a function named one_two

    uhm, no? no.

  • Custom User Avatar

    Crystal translation severely misuses testing framework and uses it blocks in a totally wrong way.

  • Default User Avatar

    C#

    There's a problem with the tests checking even distribution - my passed solution is definitely not providing an even distribution...

    Having had a look at the relavent test in the Sample Tests, I think its a simple integer division issue:

    This checks for the distribution on '1's:
    Assert.Less(Math.Abs(Integers.GetValueOrDefault(1, 0) / Length) - (1 / 3.0), Threshold);

    However the number of 1s held in Integers.GetValueOrDefault(1, 0) is not being cast to double. Therefore when its divided by the total number of digits held in the integer Length, it comes out to 0. And since the Asserts are only failing when they find a proportion greater than 1 / 3 (which would be fine if the first calculation was correct), its passing everything.

    Casting Integers.GetValueOrDefault to double in each Assert should fix it I think.

  • Default User Avatar

    Could anyone recommend some topics to study to understand this?

  • Custom User Avatar

    Ruby 3.0 should be enabled.

  • Custom User Avatar

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

  • Default User Avatar

    one_two_three': undefined method oneTwo' for main:Object (NoMethodError)
    from block in <main>' from times'
    from `'

    The instructions give a function 'oneTwo' but this function does not exist in the Ruby version, the function is actually 'one_two' this is misleading.
    Especially since "global" variables in Ruby should be prefixed with $ and this is not the case with this kata.

    My solution was accepted without the use of the this function, because I saw no way to use this function until solving it and seeing the solutions that used the given function.

  • Default User Avatar

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

  • Default User Avatar

    I'm not native speaker of English. So I don't understand what is this kata trying to do.
    Any example please?

  • Custom User Avatar

    Test specific sequences
    Test Passed
    1111 must be in sequence
    2222 must be in sequence
    3333 must be in sequence
    Test randomness
    sequence must pass randomness testCounter({1: 20000, 2: 20000, 3: 20000}) 60000

    Your goal is to create function one_two_three that returns 1, 2 or 3 with equal probability using only one_two function.

    If I understand correctly, I have to create function which returns 1, 2 or 3. But I have to return 1111, 2222, 3333 ??