def min_rotation(target_degrees, source_degrees):
    """
        Return the smallest rotation required to move
        from source angle to target angle::

            min_rotation(20, 10) => 10
            min_rotation(-340, 10) => 10
            min_rotation(20, 370) => 10
    """
    return (target_degrees - source_degrees + 180) % 360 - 180