Ad
  • Default User Avatar

    One day I will get there - nice one. Well done.

    Gave up on my brute-foce solution after many hours failed attemps and timeouts - no google used at the time lol

  • Default User Avatar

    Would you consider mine solution as cheating?

  • Default User Avatar

    Thank you for the explanations. I think that I am getting a bit closer to understand all of this.

  • Default User Avatar

    Trying to understand the complexity here, am I right to think this is quadriatic due to fact that each slice operation time complexity is (omega) O(k). So as we doing two of them it is O(k) * 2 = O(k^2). Then there is iteration cost which is O(n). Not sure if this can be seen as k elements in the list as well therefore with slicing together ending in worst case scenario complexity of O(k^2) * k or O(k^3). Does this make any sense? :-)

    Souce of info: https://wiki.python.org/moin/TimeComplexity

  • Default User Avatar

    Winner solution here in the terms of performance.

  • Default User Avatar

    I have done some time performance check of the top 5 voted solutions + mine. I knew that mine was horibble but just didn't know the scale of it - now I know lol.

    The tests were done with help of "timeit.timeit(func(strength, width), number=10000).

    Winner: falsetru with total time of 0.07845971399910923 seconds

    Timing break_the_web_mercy_madmask:

    • break_the_web_mercy_madmask (10000, 3): 0.01411 seconds
    • break_the_web_mercy_madmask (9200, 12): 0.01817 seconds
    • break_the_web_mercy_madmask (9200, 3): 0.01546 seconds
    • break_the_web_mercy_madmask (1000000000, 10000): 149.28119 seconds

    Timing break_the_web_theodaizer:

    • break_the_web_theodaizer (10000, 3): 0.00957 seconds
    • break_the_web_theodaizer (9200, 12): 0.00541 seconds
    • break_the_web_theodaizer (9200, 3): 0.01176 seconds
    • break_the_web_theodaizer (1000000000, 10000): 0.06077 seconds

    Timing break_the_web_falsetru:

    • break_the_web_falsetru (10000, 3): 0.01027 seconds
    • break_the_web_falsetru (9200, 12): 0.00502 seconds
    • break_the_web_falsetru (9200, 3): 0.0075 seconds
    • break_the_web_falsetru (1000000000, 10000): 0.05567 seconds

    Timing break_the_web_daddepledge:

    • break_the_web_daddepledge (10000, 3): 0.01955 seconds
    • break_the_web_daddepledge (9200, 12): 0.021 seconds
    • break_the_web_daddepledge (9200, 3): 0.02011 seconds
    • break_the_web_daddepledge (1000000000, 10000): 169.33592 seconds

    Timing break_the_web_pavlobarkhayev:

    • break_the_web_pavlobarkhayev (10000, 3): 0.00633 seconds
    • break_the_web_pavlobarkhayev (9200, 12): 0.02275 seconds
    • break_the_web_pavlobarkhayev (9200, 3): 0.02125 seconds
    • break_the_web_pavlobarkhayev (1000000000, 10000): 0.08437 seconds

    Timing break_the_web_nor_mal:

    • break_the_web_nor_mal (10000, 3): 0.01914 seconds
    • break_the_web_nor_mal (9200, 12): 0.023 seconds
    • break_the_web_nor_mal (9200, 3): 0.02047 seconds
    • break_the_web_nor_mal (1000000000, 10000): 239.94731 seconds