def ideal_buy_and_sell_days(arr):
    """
    given an array representing stock prices on a daily basis,
    determine the best days to buy and sell
    :param arr: an array representing a series of stock prices
    :return: a tuple containing the index of an ideal buy day, and the index of an ideal selling day
    """
    # the first element is always the lowest price at the start
    trailing_low_index = 0
    best_buy_index = 0
    best_profit = 0
    best_sell_index = None

    for i in range(len(arr)):
        # found a new low price, obviously not a buying day
        if arr[i] < arr[trailing_low_index]:
            trailing_low_index = i
            continue

        # never sell at a loss
        if arr[i] < arr[trailing_low_index]:
            continue

        # new best trading days found
        test_profit = arr[i] - arr[trailing_low_index]
        if test_profit > best_profit:
            best_buy_index = trailing_low_index
            best_sell_index = i
            best_profit = test_profit

    return [best_buy_index, best_sell_index]