Earn extra honor and gain new allies!
Honor is earned for each new codewarrior who joins.
Learn more
  • 12795864?v=3

    You have a good point there, indeed.

    I would measure it against a simple if index is even .. else loop, but that's probably not any faster. Thanks for the heads up!

  • Profile pic

    IIRC, a slice has a time complexity of O(k) (with k == the number of items). So, going over two halves of the array are roughly equivalent to going over the array once. I imagine there is a bit of overhead for the stepping, but I doubt it's much. I'm really not sure how you'd optimize this code in pure python.

  • 12795864?v=3

    Not really best practice, because you traverse the array twice, but at least it's clear :-)

  • 31073262?v=4