def getContour(semitones):
    """Return semitones in Parson's Code

    Given a list of integers defining the size and direction of a series of
    musical intervals in semitones, this function encodes the contour of the
    melody with Parsons code for musical contour where u=up, d=down, r=repeat.
    """
    contour = []
    for p in semitones:
        if p == 0:
            contour.append('r')  # repeated
        elif p > 0:
            contour.append('u')  # up
        elif p < 0:
            contour.append('d')  # down

    return ''.join(contour)