Ad
  • Custom User Avatar

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

  • Custom User Avatar

    (Deleted)

  • Custom User Avatar

    (Solved in the new fork)

  • Default User Avatar

    IMHO it breaks the 3rd zen rule of Python. At least the return expression.

  • Default User Avatar

    reverse is a boolean flag that indicates if resulting array should be sorted in ascending order from min to max, or reversed from max to min.
    i%2 is an int with value 0/1.

    In Python, an integer can also be evaluated as a boolean.
    The convention is the following:

        return False
    else:
        return True
    

    Based on this conversion rule:

    • if i % 2 == 0, then reverse == False, thus array is sorted in ascending order.
    • if i % 2 == 1, then reverse == True, thus array is sorted in descending order.