Hello all,
I am trying to solve this problem .
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15... and on so
Given three points A,B,C such that A <= B <= C. We have to report whether given points form an equilateral triangle or not .
I made this solution and but this is not considering all the cases. Here is my solution .
SOLUTION:
we know that a triangle ABC is equilateral if A==B && B==C. (equality is an equivalence relation).
So Let us consider A,B,C such that A < B < C . Now we can find the side BC as C-B+1.
Next step is to check whether the other two sides are equal to this or not .for that purpose .. we can calculate the level of each of A,B and C then take the difference.. for any nodes its level will be x A<=(x*(x+1))/2 for the smallest possible x.
comparing all the three to check the existence of an equilateral triangle .
Here is the python implementation link of the above idea http://ideone.com/V5fuhe
but this will fail on the test case 5 , 13 , 15 answer should be false but my code will report is true .
Can anyone suggest me some idea to solve this problem ..
Full text and comments »