Ad
  • Default User Avatar

    Oh nelly that was a tough one. But on the brightside it brought me back to my school days of doing maths. Was stuck on about 150 characters for hours.

  • Custom User Avatar
    • If you raise on an invalid grid, that is just a passing test, it won't stop the tests.
    • flushing: print("balbla", flush=True)
    • the behavior you describe most likely points to an infinite while loop. To spot it, you can print stuff to the console from each of your loops, to wee which one is going crazy.

    Not a kata issue => closing.

  • Default User Avatar

    Thanks for checking mate. I'll give it a go

  • Custom User Avatar

    The shortest solutions I can see in JS is about 8 lines, however most are quite larger. For example mine is 35. There are certainly mathematical elements to this kata however its far more than simply plugging in a formula.

  • Default User Avatar

    I assume that this isn't a case where there is some simple mathematical trick that if you know makes this a very easy kata to code? I ask as there's usually not a whole lot to learn from those sort of challenges (coding wise at least, though they can be interesting for those into maths theory etc) and I don't want to spend hours and hours on this only to realize there was some two line solution that uses a theorem I could have just googled. Thanks in advance

  • Default User Avatar

    Wow your code is about 10% the length of mine but finishes in about 1/3 the time. Kudos

  • Default User Avatar

    Thanks for suggestion. It doesn't seem to be working for me but thanks for replying anywyay. I'll see what I can do

  • Custom User Avatar

    If you use Python, you can print and flush it to see some value even if the code halts with a timeout. print(some_value, flush = True)

  • Default User Avatar

    Thanks. For some reason with my code in its current form the following happens:

    • I pass all 10 of the single solution tests. Then I time out and get no further (even though these get solved in about 50ms). It seems to freeze before going to ivnalid grids test and then it times out.
    • The weird thing is if I deliberately force and error during the single solutions test (I do this by saying if puzzle == one of the single test puzzles, then raise an error). What then happens is that it moves on from the single tests and goes onto the invalid and random puzzle tests, all of which I pass.

    This makes no sense to me. For some reason unless I force it to skip the single solution tests, it gets stuck there. Does anyone know why this might be please?

  • Custom User Avatar

    12000ms limit is the total time limit.

  • Default User Avatar

    It is frustrating that my code keeps timing out without any indication as to when it was that I timed out. By using older code I am able to see the 10 invalid tests but for some reason I don't even get that far with my new, better code. I know it is better because I ran the invalid tests in Spyder and pass them much much quicker than the older code.

    Does anyone know where I can access the random tests please? Also, is the 12000ms limit the total time limit or the time limit per test section? Thanks

  • Default User Avatar

    I got the exact same results as you on the tests you mentioned. For "wfcairbxklyqnhupvmes" I got "myxwvusrqpnlkihfecba" and same for the second one. Do not know if we are wrong or the solution is wrong.

  • Default User Avatar

    I borrowed the sieve from elsewhere online (have credited original creator) -this just allowed me to list primes below n to save iterating through non primes. The rest is mine.