**izard**

Here is the code for the previous post

I should have wrote this code in the first place, took me only 5 minutes anyway.

But my proof of O(n^3) still stands, and I found a German university computer science textbook that also proves it should be O(n^3) in the worst case... Riddles!

I should have wrote this code in the first place, took me only 5 minutes anyway.

**spamsink**was right: apparently in runs in slightly below O(n^2).But my proof of O(n^3) still stands, and I found a German university computer science textbook that also proves it should be O(n^3) in the worst case... Riddles!