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.
Checking if the points lies inside a square can be done without any floating point operations. Two hints (References almost contain the solution to this problem. Do not open them if you still want to figure your own way out just by using the hints) :
You can calculate the other veticies of the squre using the two diagonal points given using some maniputaion of vectors. The only factor of division by 2 can be taken to the other side of the inequalities while comparison, to avoid division. Reference
The actual condition for checking if point is inside the squre can be either done by the method of comparing the sum of areas or even better the dot product of edges of squre and the vector from vertex to point.Reference
This tutorial section is very educational. 1 carat diamond engagement ring price Thanks for holding it. This section on circle and square is very much informative and helps the students to learn maths in a very interesting way. All the doubts can be discussed here and hence can be solved.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Join us
Create a HackerRank account
Be part of a 26 million-strong community of developers
Please signup or login in order to view this challenge
A Circle and a Square
You are viewing a single comment's thread. Return to all comments →
Checking if the points lies inside a square can be done without any floating point operations. Two hints (References almost contain the solution to this problem. Do not open them if you still want to figure your own way out just by using the hints) :
calculating the 3rd vertex is itself a difficult task
This tutorial section is very educational. 1 carat diamond engagement ring price Thanks for holding it. This section on circle and square is very much informative and helps the students to learn maths in a very interesting way. All the doubts can be discussed here and hence can be solved.