Sherlock and Planes

Sort by

recency

|

34 Discussions

|

  • + 0 comments
    def solve(points):
        # Write your code here
        x = set([i[0] for i in points])
        y = set([i[1] for i in points])
        z = set([i[2] for i in points])
        if len(x) == 1 or len(y) == 1 or len(z) == 1:
            return 'YES'
        return 'NO'
    
  • + 0 comments

    Do you know any sherlock who can get best consultancy in dubai for canada that suitable for students.

  • + 0 comments

    python3

    def vector_sub(a,b):
        return list(map(lambda x,y: x-y, a, b)) 
    
    def cross(a,b):
        return [a[1]*b[2] - a[2]*b[1],
                a[2]*b[0] - a[0]*b[2],
                a[0]*b[1] - a[1]*b[0]]
    
    def dot(a,b):
        return sum([x*y for x,y in zip(a,b)])
    
    def solve(points):
        # use the 4 points p,q,r,s to make vectors pq,pr,ps 
        pq = vector_sub(points[1], points[0])
        pr = vector_sub(points[2], points[0])
        ps = vector_sub(points[3], points[0]) 
        # cross product of pq and pr gives the normal vector
        n  = cross(pq, pr)
        # if the vector ps is orthoginal to n 
        # then the point lies on the plane
        if dot(n, ps) != 0: 
            return 'NO' 
        return 'YES'
    
  • + 0 comments

    def solve(points):

    # Write your code here
    x = []
    y = []
    z = []
    for i in range(4):
        x.append(points[i][0])
        y.append(points[i][1])
        z.append(points[i][2])
    xx = list(set(x))
    yy = list(set(y))
    zz = list(set(z))
    if(len(xx)==1 or len(yy)==1 or len(zz)==1):
        return "YES"
    else:
        return "NO"
    
  • + 0 comments

    def solve(points):

    # |  x - x1   y - y1   z - z1 |
    # | x2 - x1  y2 - y1  z2 - z1 |  = 0
    # | x3 - x1  y3 - y1  z3 - z1 |
    
    x1, y1, z1 = points[0][0], points[0][1], points[0][2]
    x2, y2, z2 = points[1][0], points[1][1], points[1][2]
    x3, y3, z3 = points[2][0], points[2][1], points[2][2]
    
    a = ((y2-y1) * (z3-z1)) - ((z2-z1) * (y3-y1))
    b = ((x2-x1) * (z3-z1)) - ((z2-z1) * (x3-x1))
    c = ((x2-x1) * (y3-y1)) - ((x3-x1) * (y2-y1))
    
    for x, y, z in points[3:]:
        val = a*(x-x1) - b*(y-y1) - c*(z-z1)
        if val != 0:
            return "NO"
    
    return "YES"