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.
The solution method proposed by the editorial is non-obvious and possibly more complicated than it needs to be. A more intuitive and straightforward method (to this former vector calculus teacher) is to use parametric equations to describe the beampath and the wall. If Ri is the vector = , then problem can be rewritten " Does there exist an s and t (both between 0 and 1) so that s*R2 + (1-s)*R1 = t*Rm. From there it is straightforard linear algebra. The only special case that needs any particular care is the case where the lines are parallel, so the equations are indeterminate.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Jim Beam
You are viewing a single comment's thread. Return to all comments →
The solution method proposed by the editorial is non-obvious and possibly more complicated than it needs to be. A more intuitive and straightforward method (to this former vector calculus teacher) is to use parametric equations to describe the beampath and the wall. If Ri is the vector = , then problem can be rewritten " Does there exist an s and t (both between 0 and 1) so that s*R2 + (1-s)*R1 = t*Rm. From there it is straightforard linear algebra. The only special case that needs any particular care is the case where the lines are parallel, so the equations are indeterminate.