Ad
  • Custom User Avatar

    If this was solved on your own and not via GPT Chat, you are a genius.

  • Custom User Avatar

    Approved.

  • Custom User Avatar

    You're mutating the input list. That was the reason why it failed. I've approved the fork below so tampering with it won't be a problem anymore.

  • 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

    I agree this should be explained in the kata better. Knowing this helped me solve this much faster.

  • 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
    '112123123412345123456123456712345678123456789123456789101234567891011123456789101112123456789101112131234567891011121314'[100-1] (1 based) => 1 not 9
    
  • 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

    Cool! I did calc for squares only one time. Where do you store the sequences? Tuples or sets or...? My time for 10M is 17 sec for now, but I did start from 25 sec ))) Your results is awesome!

  • Custom User Avatar

    Just avoid list and repeated calc of the squares. Both is taking a lot of time. My results in sec:

    n = 1.000: 0.0002543900000091 sec
    n = 10.000: 0.0019760499999847 sec
    n = 100.000: 0.0156731199999967 sec
    n = 1.000.000: 0.1389633400000093 sec
    n = 10.000.000: 1.4097446399999853 sec

  • Custom User Avatar

    I've just found that the last test will take v=10E7...))) on 5 mln I had the best time 9 sec. I am in stuck! it's pretty upsetting me!

  • Custom User Avatar

    I have been working on this kata 2 days. First algorithm I've made for 10 min and it goes through simple tests, but for big test (n=5 mln) I can't made it faster then 10 sec. I will improve it and I like this task, but I think this kata is harder then 5kyu. Also it would be good to accent in the task on test for really big sequences.

  • 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

    Please see description and example test cases.

    for n = 100, there are only 3 numbers that meet the requirement. They are 5, 55, 77.

    for n = 1000, there are only 11 numbers.

  • Loading more items...