(position, next_position)
Get the direction such that position --> next_position.

    We assume that they are adjacent.
Get the direction such that position --> next_position.
Get the direction such that position -- > next_position .
def get_direction(position, next_position):
    """Get the direction such that position --> next_position.

    We assume that they are adjacent.
    """
    x, y = position
    next_x, next_y = next_position
    if x == next_x:
        if y < next_y:
            return constants.Action.Right
        else:
            return constants.Action.Left
    elif y == next_y:
        if x < next_x:
            return constants.Action.Down
        else:
            return constants.Action.Up
    raise constants.InvalidAction(
        "We did not receive a valid position transition.")
def get_direction ( position , next_position ) : x , y = position next_x , next_y = next_position if x == next_x : if y < next_y : return constants . Action . Right else : return constants . Action . Left elif y == next_y : if x < next_x : return constants . Action . Down else : return constants . Action . Up raise constants . InvalidAction ( "We did not receive a valid position transition." )