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? :-)
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
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
Would you consider mine solution as cheating?
Thank you for the explanations. I think that I am getting a bit closer to understand all of this.
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
Winner solution here in the terms of performance.
And I took that personally so I optimized it in a fork.
Unfortunately, it did end up looking like falsetru solution. :/
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:
Timing break_the_web_theodaizer:
Timing break_the_web_falsetru:
Timing break_the_web_daddepledge:
Timing break_the_web_pavlobarkhayev:
Timing break_the_web_nor_mal: