I try to translate this function someone made to help me, but I only know PHP so I tried to translate it.
Python :
def Sous(dist,d) : # Étant donné