Ad
  • Custom User Avatar

    Manually checked the log, solution is correct.

    Random tests always fail with:

      File "/workspace/default/.venv/lib/python3.10/site-packages/codewars_test/test_framework.py", line 112, in wrapper
        func()
      File "/workspace/default/tests.py", line 32, in random_test_case
        test.assert_equals(cup_and_balls(b2,qwe2), cup_and_ballsFed(b1, qwe1))
      File "/workspace/default/tests.py", line 7, in cup_and_ballsFed
        if b == i[1]: b = i[0]
    IndexError: list index out of range```
    
  • Custom User Avatar

    Cheater! :) j/k. Clever

  • Custom User Avatar

    Ah, the interepretation here is that the element to be returned is the digit not the number.

  • Custom User Avatar

    Manually writing out the list:

    [1, 12, 123, 1234, 12345, 123456, 1234567, 12345678, 123456789, 12345678910, 1234567891011, 123456789101112, 12345678910111213, 1234567891011121314]

    Note that the 100-th element is the 9 in the 1234567891011121314 group, whose last element (14) is 105-th position in the "master" combined sequence.

    Note sure why Assert::That(solve(100),Equals(1)); expects the 100-th element to be 1.

    What is missing in this interpretation ?

  • Custom User Avatar

    Thanks for the response.

    The clarification is with the description. I wasn't sure if, for example, {2^2} is a valid sequence (sum of 1 elements). The min length of the sequence is not specified.

    Either way, if min length of valid sequence is 2, then the test cases hold.

    Cheers.

  • Custom User Avatar

    Clarification: legitimate sequences would be {1^2 + 2^2}, {1^2 + 2^2 + 3^2}, ..., {2^2}, {2^2 + 3^2}, {2^2 + 3^2 + 4^2}, ..., etc, right ?

    If so, for n = 100 you get 5 and for n = 1000 you would get 16. Not sure if I have understood the explanation correctly. Any suggestions would be appreciated.

  • Custom User Avatar

    Then I don't get this error:

    Expected: equal to Max, John and Mark like this
    Actual: Max, John and Mark like this

  • Custom User Avatar

    C++: Test cases start with "equal ... ". Per instructions, this should not be there.