Ad
  • Custom User Avatar

    Benjamin, thank You very much for this suggestion!
    If fact, I was playing a while with replacing 'i' with 'j' and didn't commented in the end.
    At my desktop this unoptimized code runs fine (8 cores CPU and 32 GB RAM), but in this environmnet it stops after passing medium tests:
    Medium tests (3 of 3 Assertions) OK.
    But by large tests I've got twice well-known STDERR: Large tests Execution Timed Out (12000 ms).
    So maybe instead of two for loops (by i and by j to summarize elementVal = 1 * i + 2 * j + 1 ) should I switch to an generator plus lambda function ...?
    Well, its time to open math books or Calculus manual and come back to Mr Euler's elegant solution...

  • Custom User Avatar

    Hi! I was trying with the double for loop, but after 1 sec. a standard error has rised ( Error 137: Max Buffer Size Reached 1.5MB), and now I see that I need a formula rather, not lopp. Well, finally I have understood the meaning of this final note about avoiding a brute force ...

  • Custom User Avatar

    Thank You for this tip!

    I've just noticed that not only the print () function was redundant as a result.
    I stared at the sample answer and absolutely wanted mine to be the same as a string.
    Therefore, I have added single apostrophe on both sides. So the answer was the same on the printout.
    I was confused that as the correct output our Sensei gave the result in double quotation marks,
    ["hay", "junk", "hay", "hay", "moreJunk", "needle", "randomJunk"] -> "found the needle at position 5" -
    instead of this text without them. The better is the enemy of the good. ... B

  • Custom User Avatar

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