Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
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.

q4.t
Description:
 Question 4 code

Filename:  q4.t
Filesize:  944 Bytes

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).
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 7 Posts ]
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: