Ad
  • Custom User Avatar

    See above, this occurs when you print the integer value.

  • Custom User Avatar

    Remember: if J comes before I in the key, then it's J that goes into the matrix rather than I, in short whoever comes first goes into matrix but will be used as both i and j

  • Custom User Avatar

    482 is correct:

    In[16]: 3 ** (3 ** 3)
    Out[16]: 7625597484987
    In[17]: pow(3, _, 1001)
    Out[17]: 482
    
  • Custom User Avatar
  • Custom User Avatar

    Hey @ihatemaths - thanks for your lovely message, it made my afternoon reading it! I thought I was one of the older people on the site, but you have me beat.

    My neighbor (79 years young) decided to take up triathlon last year and now I see him every other day in my town practicing his cycling - and I live in a mountain region! - so never say never about the maths learning ;)

    Happy new year and I hope you have a great 2023

  • Custom User Avatar

    Hi @ihatemaths (nice username!),

    I copied your current solution locally, and performed a test with two inputs:

    a=0, b=10 -> returns 3 (this is the test in the Description)

    a=0, b=11 -> returns 4 this is incorrect, because the kata expects 3 if I'm not mistaken. Note that here, going from b=10 to 11 we have that 11 is an upside down number.

    The description says: "For example, solve(0,10) = 3, because there are only 3 upside down numbers >= 0 and < 10 so as you can see here the upper limit is NOT inclusive

    So tl;dr, it seems your code is currently counting the upper range limit value, when it should not.

  • Custom User Avatar

    Very appropriate username by the way ;)

  • Custom User Avatar

    Easy, first use this:

    def green(n):
        print(n)
        pass
    

    You'll see there are 108 tests and the aproximate values that are tested.

    To see which one your code times out with, use print like this: print(n, flush=True)

    P.S.: despite hating maths, you try a lot of math katas ;)

  • Custom User Avatar

    It is possible that you found a bug in the kata, but you need to provide enough information to both prove it and help us to locate the bad code. Please provide all of the following:

    1. The language your attempt is in (don't expect us to be able to infer it from your message)
    2. the captured input (via a print statement)
    3. your output (via a print statement)
    4. the error/assertion text (this is always a must -- it captures the expectation of the test).

    This helps determine where the issue lies. Note that Kata authors often swap expected and actual arguments in assertions (item 3); in doing so, their kata are still correct in terms of asserting algorithmic correctness (it is just that error output is misleading.) So a correct implementation still passes the tests and an incorrect implementation will still fail the tests. This is the sort of thing we can fix without invalidating everyone's solutions. This "correct kata but misleading error reports" quality exists in lots of kata on CW (perhaps half or more) - expect to see it time and again on CW.

    If you don't have a (4) because of a time-out, you need to tune your algorithm to complete within the 12 seconds that CW allows.

  • Custom User Avatar

    Suffice it to say I don't think I have a problem with my solution.

    I've put a lot of work into my solution and to be told it fails is not acceptable.

    This smacks of arrogance to me.

    Provide some proof your code is right and the tests are wrong then. As I said, to evaluate that, the input value is something we need. And in the link there are instruction on how to post your code, that's the only way we can see it and try to help you figure it out where the problem is.

  • Custom User Avatar

    You are most probably reading logs incorrectly and misinterpreting them. I jsut solved the kata with Python, and it seems to work correctly.
    I still believe your solution does not handle some edge cases correctly. I updated tests to present (hopefully) better assertion messages, so you can try and re-run your solution and check the errors now. You can also post your code (remember about formatting and spoiler flag), and we could help you find your mistake.

  • Custom User Avatar
  • Custom User Avatar

    How big may depend on which language you intend to try.
    In general think "big enough that a solution will require some careful coding to complete in the 12 second code wars time limit."
    Larger than 32 bit numbers.

  • Custom User Avatar
  • Custom User Avatar
  • Loading more items...