Ad
  • Custom User Avatar

    Genralized tip:

    def kata_solution(arg):
        print(arg)
    

    You'll fail all the test, but usually you'll see the input. (Except, as you'll discover here, not always.)

    def kata_solution(arg):
      pass
    

    Often this will help you find out the count of tests. (Although, again not always.)

    I was able to reach 65 tests, but still timed out. I suspect we're using the same algorithm (but I've optimized mine as much as possible). I have in mind another algorithm which I think may be faster, but don't have time to implement it at the moment. I'd encourage you to try a different approach. 232 people have solved it in Python, so it should be doable.

    No spoilers, sorry. :)

  • Custom User Avatar

    Funny solving this one...

  • Custom User Avatar

    Since the SecurityManager is deprecated since Java 17 and permanently deactivated since Java 24 this kata likely doesn't have a chance to ever be working again in upcoming Java versions.

  • Custom User Avatar

    Why not just check all lowercase and all uppercase letters?

    You could do that, and then also add random tests on top.

  • Custom User Avatar
  • Custom User Avatar
  • Custom User Avatar

    fork provided for JS

    EDIT: temporarily unpublished to fix refSol

    SECOND EDIT: okay, it's now ready to be vetted

  • Custom User Avatar

    in C: random tests don't excite all paths in solution, allowing incorrect code to pass all tests.
    Some cases not covered by default:

      dotest (16,8448,8449);
      dotest (7,5935,4);
    

    but others might also be missing. You can try to find them by running tests 10+ times.

  • Custom User Avatar
  • Custom User Avatar
  • Custom User Avatar

    hi there!
    my code passed 55 (example + short), but T.O in large ones.
    running python.
    already O(log n), and not sure how to reduce it further.
    was it tested using python on servers? can it get better than O(log n)?

    edit:
    on my 6y.o laptop i get 50 tests of 106-digits in split of a second:
    number: 1234567890123456789111111111111111111111111111111111112345678901234567891111111111111111111111111111111111 size: 350 array: [1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1]
    Action took 0.00 seconds

    how big are the big numbers?

  • Custom User Avatar

    The representation with the shortest length of "digits" (1 or -1).

  • Custom User Avatar

    What does "the least" mean??

  • Custom User Avatar

    Random tests added in C, C++, Java, and JavaScript.

  • Custom User Avatar

    approved

  • Loading more items...