Ad
  • Custom User Avatar

    Look at what the tests do:

    jar = Jar()

    Each instance of the class is initialized without parameter. But that doesn't mean you cannot create some variables in __init__ for your convenience. That's what you need to figure out and it depends on how you solve the kata.

  • Default User Avatar

    Glad you solved it! I was just replying to say that your solution looked fine to me then I saw your updated message.

    Any "way of doing things" is an algorithm - as you just saw with this exercise, just because it's simple doesn't mean it's not powerful (your second "algorithm" finds the same result as your first attempt, but much much faster!).

  • Default User Avatar

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

  • Default User Avatar

    Hi @conconTheCoder - Yes this is the expected behavior for the tests; your solution with 2 for loops will pass the BASIC test cases since the maximum size in the basic tests is N = 10.

    In the FULL tests, i.e. when you click "Attempt" in the kata, your algorithm will be tested on values of N = 41,000. This is designed to time out brute force solutions with 2 for loops. The timeout limit is = 12 seconds on Codewars Python katas.

    You can generate a random 41000 x 41000 board on your computer/IDE and see how long your current solution takes with an input of this size! (don't actually do this, it will take hours and/or crash your computer - test your algorithm on boards of size N=100, 200, 300... and notice how much time it is taking to find the solution)