def is_stepwise_motion(melody, position):
    """
    Returns true if the note at position in the melody is in the middle of a
    step-wise movement in a single direction.
    """
    pre_note = melody[position - 1]
    note = melody[position]
    post_note = melody[position + 1]
    step_to = abs(pre_note - note)
    step_from = abs(note - post_note)
    if step_to == 1 and step_from == 1:
        return pre_note != post_note
    return False