Earn extra honor and gain new allies!
Honor is earned for each new codewarrior who joins.
Learn more
  • That was quite illuminating. My first algo took 10 mins for all numbers in (1, 1000) on my old Mac. Easy fix got it down to 80 sec. Then a day of thinking - down to 24. Then i added two adjustements to the algo, which i was certain would improve it significantly. Especially checking if the current vertex was already investigated in the current branch and what was the maximum depth achieved etc. But all that only slashed another 4 sec to 20! :) Still was enough to pass.
    I definitely know python a bit better now.

  • Anything wrong with this?

  • Thanks guys, FIXED IT AND Passed everything nicely, Done!

  • I updated the assertion message so that it gives you the value of n.

  • IIRC, "Unhandled rejection" means simply failed assertion in JS tests. You solution passes 1165 tests, failed one assertion and then stopped. Reason for your failure is given with the assertion message, "Not an array", so probably tests expect an array and you return something else (undefined?)

  • ok, sounds like your code doesn't return an array when it should, for one input. If you deploy the "verify" block, in red, you should see the value of n causing that.

    Note: I just changed the upperlimit for various languages (some were easier than others) => the top value of N is 1300 in JS, now.

  • https://snipboard.io/ujOKy6.jpg Here's a screenshot for reference, I guess there is something I may not notice but unfortunatelly I can not find it under failed tab

  • Negative, it passed all 1165 tests in 2,3seconds, you see...
    So there are 1166?? It gives me somewhere an error, but why can not I see this error?

  • I guess you have a "time out" error? Then you didn't pass all tests at all, your solution is just too slow (if you passed all tests, you should see 1466 succesfull tests, in JS)

  • Hey, I passed all tests but 1 fails and says Unhandled rejection error, can you please tell me how to handle it? I have no idea... What causes it?

  • .

  • Guys, it's purple level. You can see the number of tests in the descritpion. For python, all values are tested up to 1000, iirc, meaning that an algo building a solution for 1000 in 1,3s is just like 1000 times too slow (almost).

    the C++ version isn't up to date, iirc (I'll have to clear the things with new issues, I guess). And I don't know what are the optimisation flags used when compilming the code so... cannot really tell.

  • some tags are automatic. This one is and shouldn't be there, yes...

  • I think the Python solution should be required to return None, not False, when there is no solution.

    true, but that would invalidate previous valid solutions, so I kept it that way when I updated the kata.

  • Beautiful kata, the most rewarding for me so far, thank you!

    I figured out the high level solution and coded a rough implementation fairly quickly, only to find out that it would take ages for large n. I thus spent a lot of time reading scientific papers and book excerpts to educate myself on the optimization techniques to increase the efficiency of my solution.

    A small remark: I think the Python solution should be required to return None, not False, when there is no solution.

  • Loading more items...