Ad
  • Custom User Avatar

    Thanks! It's been too long since I played sudoku, I needed this reminder.

  • Custom User Avatar

    Look the numbers in regions 3x3.
    In every region you have duplicate numbers:

    ex.
    first region 3x3

    1 2 3
    2 3 4
    3 4 5

    As you can see 2,3 and 4 are duplicated, and there are not all the numbers between 1 and 9, so it returns 'Try again!'.

  • Custom User Avatar

    Actually i am stuck in buliding the correct logic....
    if you can help me a little.....:)

  • Custom User Avatar

    Did you solved it??

  • Custom User Avatar

    You can use that, which is enough for the tests:

    import sys
    sys.setrecursionlimit(2000)
    

    With 2000 you're never going to get into trouble. But there is a limit for a reason, and if you ever need 1,000,000 levels of recursion, you can't just increase the recursion limit, you'll have to rewrite the algorithm iteratively.

  • Custom User Avatar

    The second option.

  • Custom User Avatar

    "Completing a battle against an enemy who is two levels lower or more than your warrior will give 0 experience points."
    Does this line means that "battle against an enemy who is 2 levels lower or 2 levels higher than warrior"
    or it means "battle against an enemy who is 2 or more levels lower than warrior"

  • Custom User Avatar

    hey @marcos.h3, I was also trying the same method using itertools.permutaions at starting but this method is slow as the test cases in CW contains some numbers having 14 digits and at that point the the permutations method takes a lot of time to work. You need to find a patern in the answer you want and you will be able to develop a logic that works fast enoough.

  • Custom User Avatar

    hey @luiseduardobr1, I was also trying the same method using itertools.permutaions at starting but this method is slow as the test cases in CW contains some numbers having 14 digits and at that point the the permutations method takes a lot of time to work. You need to find a patern in the answer you want and you will be able to develop a logic that works fast enoough.

  • Custom User Avatar

    Yes, this kata is quite good. After trying so many logics finally I found the fastest one.
    Took hours to solve this kata, But loved it.

  • Custom User Avatar

    CWE is likely to be slower than a local IDE; however, this is a pretty kata not a brute force one - change your algorithm!

  • Custom User Avatar

    I havent solved the kata in Python, but Java and C# test suites have 150 tests, and my solution executes whole test suite below 1s (plus VM startup time, so ~3-4s total). I would expect Python version have similar constraints.
    I think your solution might still be improved. I wonder what kind of logic you came up with?

    EDIT: 150 tests in Python, done in ~1s. I think you need to improve your idea, or the way you implemented it.

  • Custom User Avatar

    Even I tried the same code on 300 random numbers of 10 digits each. Still the local IDE complets the task in less than 12 seconds.I don't know why CWE is showing "Execution timed out" error....?

  • Custom User Avatar

    Finding a logic is not that much hard but a logic that can generate results in limited time is a bit difficult.
    But after trying finaly i found a logic that works within time limit in local IDE.
    I genertated 200 random numbers of 9-10 digits and used the function to get the next greater number for each of the 200 numbers.
    And it takes average around 6-8 secs(calculated using time module) to generate the results.
    But while attempting it in CWE shows "Execution timed out".....

  • Custom User Avatar

    Because your recursive calls aren't resolved until very end, they quickly fill up the call stack and crash the program, for a good reason :P Otherwise it could cause a buffer overflow.

  • Loading more items...