We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
defvector_sub(a,b):returnlist(map(lambdax,y:x-y,a,b))defcross(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]]defdot(a,b):returnsum([x*yforx,yinzip(a,b)])defsolve(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])#crossproductofpqandprgivesthenormalvectorn=cross(pq,pr)# if the vector ps is orthoginal to n # then the point lies on the planeifdot(n,ps)!=0:return'NO'return'YES'
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Sherlock and Planes
You are viewing a single comment's thread. Return to all comments →
python3