import math


def one_dim_peak(arr, pointer = 0):
    """
    Find a 'peak' in a 1d array, giving value and position. given a list [a0, a1, ... , an-1] a peak
    is defined where for ai, ai-1 <= ai and ai+1 <= ai.
    >>> one_dim_peak([1,2,3,4,5,2,1])
    (5, 4)
    """
    #Base case [We consider singletons to have a peak]
    if len(arr) == 1:
        return (arr[0], pointer)
    
    #Initialize our midpoint. I decided to use a left-bias in my binary search algorithm.
    mid = math.floor((len(arr) - 1)/2)
    left = mid > 0 #Prevent out-of-range error for edge cases
    
    #Recursive case
    if arr[mid - 1] > arr[mid] and left: 
        #Left side of our midpoint has a peak
        return one_dim_peak(arr[0:mid], pointer)
    elif arr[mid + 1] > arr[mid]:
        #Right side of midpoint has a peak
        return one_dim_peak(arr[mid+1:len(arr)], pointer + mid + 1)
    else:
        #We've obtained a peak, so return its value and index.
        return (arr[mid], mid)