dimanche 23 août 2020

That is the difference [closed]

I am using Python3

class Solution:

    def __init__(self, radius: float, x_center: float, y_center: float):
        self.cenx = x_center
        self.ceny = y_center
        self.r = radius
    def randPoint(self) -> List[float]:
        #switch to polar coordinates
        phi = (2*random.random() - 1) *pi
        r = (random.random() * (self.r)**2)**0.5
        res = [self.cenx + r*cos(phi), self.ceny + r*sin(phi)]
        return res

What is diff between random.random()*(self.r) and (random.random()*(self.r)**2)**0.5 if I use random.random()*(self.r) I am getting Wrong Answer in one test case

Problem link




Aucun commentaire:

Enregistrer un commentaire