Round 1 Question 4
Author 
Message 
crossley7

Posted: Mon Nov 01, 2010 11:40 am Post subject: Round 1 Question 4 


Our team tried doing area of triangles to solve this during the contest but after the contest we found a simple solution in turing, wonder if there is a better one.
This is the code, it basically draws a triangle and checks if the house is in the triangle formed.
Description: 

Download 
Filename: 
q4.t 
Filesize: 
944 Bytes 
Downloaded: 
211 Time(s) 






Sponsor Sponsor



A.J

Posted: Mon Nov 01, 2010 8:53 pm Post subject: RE:Round 1 Question 4 


Good job crossley7!
Yes, this indeed was the simplest solution for Turing programmers. I expected a few teams to come up with this (and I am not sure whether any did during the contest or not).
However, the 'intended' solution was checking whether the signs of the dot products where the same. Another solution involves computing the areas of the triangles formed by every pair of vertices in the triangle and the origin, and checking whether the sum of these areas is equal to that of the triangle itself.






crossley7

Posted: Tue Nov 02, 2010 8:23 am Post subject: Re: Round 1 Question 4 


yeah, in the competition the solution we were trying until the time ran out was calculating the area of the 3 smaller triangles with the area of the large one. But found after the contest that the best solution was to switch to turing and just draw on the screen. But hopefully we can do better next contest, I had a few bad moments and submitted code that didn't work because of some simple things. so instead of 84th we would have been top 30. oh well, there is always next contest






A.J

Posted: Tue Nov 02, 2010 12:48 pm Post subject: RE:Round 1 Question 4 


See, I want to emphasize that your ranking in this contest shouldn't be what's important to you. The only team you should be competing with is yourself. Strive to do better than you did the previous round, and you'll do fine.






Dan

Posted: Tue Nov 02, 2010 8:16 pm Post subject: Re: Round 1 Question 4 


crossley7 @ 2nd November 2010, 8:23 am wrote: yeah, in the competition the solution we were trying until the time ran out was calculating the area of the 3 smaller triangles with the area of the large one. But found after the contest that the best solution was to switch to turing and just draw on the screen. But hopefully we can do better next contest, I had a few bad moments and submitted code that didn't work because of some simple things. so instead of 84th we would have been top 30. oh well, there is always next contest
In terms of simplest soultion, Java has a polygon class which has a contains method for testing a point or rectangal, which would be more efficent then drawing to the screen. However i would not consdier either the best soultion.
Unforntaly it is not allways possible to make questions that are equally cahalgening in all languaes, as AJ pointed out DWITE should be viewed as practice. Simply using bulit in functions/methods of a langue might get you done fast but it does not teach you much about the problem.

Computer Science Canada
Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more! 




Shanethe13

Posted: Tue Nov 02, 2010 9:10 pm Post subject: Re: RE:Round 1 Question 4 


A.J @ Mon Nov 01, 2010 8:53 pm wrote: However, the 'intended' solution was checking whether the signs of the dot products where the same.
I hadn't thought of that solution, it's a lot cleaner than what I had though (the area method). Although, looking at it now, would it work to plug (0,0) into the standard form equation for each of the triangle's sides, comparing the sign of the result with the opposite side lengths? It should work for a rectangle, but I'm not sure if the lack of parallel sides in a triangle might affect things. Of course, I suppose you could construct another side length using the opposite point, testing for each of the three sides. I guess I may have to program this and see






A.J

Posted: Wed Nov 03, 2010 1:16 am Post subject: RE:Round 1 Question 4 


One only learns by applying the things they have learned (though some people may disagree with me).







