Velocity Reviews > Java > Challenge: Triangles puzzle

# Challenge: Triangles puzzle

Jim Newton
Guest
Posts: n/a

 10-16-2004
Sorry, but i do not agree with your solution.
You missed many triangles.

E.g., P0 -> P8 -> P5 -> P0 is a triangle of zero area.
but it is not counted in th solution of 27.

-jim

Frank Buss wrote:
> I've setup a challenge, mainly for C++, Java and Lisp, but every other
> language is welcome:
>
> http://www.frank-buss.de/challenge/index.html
>
> There is nothing to win, but I hope there will be some interesting
> solutions at the end, so the win are the results
>

Frank Buss
Guest
Posts: n/a

 10-16-2004
I've setup a challenge, mainly for C++, Java and Lisp, but every other
language is welcome:

http://www.frank-buss.de/challenge/index.html

There is nothing to win, but I hope there will be some interesting
solutions at the end, so the win are the results

--
Frank Buß, http://www.velocityreviews.com/forums/(E-Mail Removed)
http://www.frank-buss.de, http://www.it4-systems.de

Frank Buss
Guest
Posts: n/a

 10-16-2004
Jim Newton <(E-Mail Removed)> wrote:

> Sorry, but i do not agree with your solution.
> You missed many triangles.
>
> E.g., P0 -> P8 -> P5 -> P0 is a triangle of zero area.
> but it is not counted in th solution of 27.

you are right, this was not exact enough, I've updated the web page. Only
triangles with area>0 should be counted.

--
Frank Buß, (E-Mail Removed)
http://www.frank-buss.de, http://www.it4-systems.de

Yogo
Guest
Posts: n/a

 10-16-2004
> Sorry, but i do not agree with your solution.
> You missed many triangles.
>
> E.g., P0 -> P8 -> P5 -> P0 is a triangle of zero area.
> but it is not counted in th solution of 27.

hmm...

A triangle with an area equal to zero doesn't exist. A triangle has three
angles and none of them may be equal to zero, otherwise you just don't have
a triangle.

What you describe with P0 -> P8 -> P5 -> P0 is a segment of a line not a
triangle...

Sudsy
Guest
Posts: n/a

 10-16-2004
Frank Buss wrote:
> I've setup a challenge, mainly for C++, Java and Lisp, but every other
> language is welcome:
>
> http://www.frank-buss.de/challenge/index.html
>
> There is nothing to win, but I hope there will be some interesting
> solutions at the end, so the win are the results
>

--
Java/J2EE/JSP/Struts/Tiles/C/UNIX consulting and remote development.

Mikael Brockman
Guest
Posts: n/a

 10-16-2004
Frank Buss <(E-Mail Removed)> writes:

> I've setup a challenge, mainly for C++, Java and Lisp, but every other
> language is welcome:
>
> http://www.frank-buss.de/challenge/index.html
>
> There is nothing to win, but I hope there will be some interesting
> solutions at the end, so the win are the results

Thanks Frank. Fun way to waste half an hour.

Raymond Martineau
Guest
Posts: n/a

 10-17-2004
On Sat, 16 Oct 2004 23:29:52 +0200, "Yogo" <n o s p a m> wrote:

>> Sorry, but i do not agree with your solution.
>> You missed many triangles.
>>
>> E.g., P0 -> P8 -> P5 -> P0 is a triangle of zero area.
>> but it is not counted in th solution of 27.

>
>hmm...
>
>
>A triangle with an area equal to zero doesn't exist.

Not as far as a computer is concerned. Without any form of sanity
checking, the most intuitive (read: quickest for the programmer to
implement) definition of a triangle for a computer is a set of three
points.

The puzzle in question only considers triangles to be formed from a given
set of points, as well requiring a known line connecting between those
points. Although the puzzle didn't define triangle, the webpage now
includes an update that requires these traingle to have an area.

>A triangle has three
>angles and none of them may be equal to zero, otherwise you just don't have
>a triangle.
>
>What you describe with P0 -> P8 -> P5 -> P0 is a segment of a line not a
>triangle...

Using the "three angles" definition, the line given is valid. There are
three angles in the shape:

P5 -> P0 -> P8 : 0 degree angle
P0 -> P5 -> P8 : 180 degree angle
P0 -> P8 -> P5 : 0 degree angle.

0 degrees is still an angle, as is 180. These angles are generally
significant as they indicate parallel lines, but can be valid in figures.

Tayssir John Gabbour
Guest
Posts: n/a

 10-17-2004
Frank Buss <(E-Mail Removed)> wrote in message news:<cks0s2\$6a9\$(E-Mail Removed)>...
> I've setup a challenge, mainly for C++, Java and Lisp, but every other
> language is welcome:
>
> http://www.frank-buss.de/challenge/index.html
>
> There is nothing to win, but I hope there will be some interesting
> solutions at the end, so the win are the results

Would it be possible for you to have a private mailing list where you
can show us peoples' submissions? I'm too impatient to wait until the
25th. The recipients can be people who already sent you solutions.

It is interesting to see how one programs differently when shipping
time is a factor. After I sent it to you and took a quick look at the
code, I realized I left in parameters named "blah". Which is what I
frequently name things, but I always rename them.

MfG,
Tayssir

Jeff
Guest
Posts: n/a

 10-17-2004
Tayssir John Gabbour wrote:

> It is interesting to see how one programs differently when shipping
> time is a factor. After I sent it to you and took a quick look at the
> code, I realized I left in parameters named "blah". Which is what I
> frequently name things, but I always rename them.

How very true. I'm also curious to see if anyone comes up with a
"general case" solution to the problem. I'm in the console gaming
industry, where most of the time hard-coding a solution to a specific
problem is preferable -- which is why I did in this case.

Jeff M.

Jim Newton
Guest
Posts: n/a

 10-17-2004

>
> hmm...
>
> What are you talking about?
>
> A triangle with an area equal to zero doesn't exist. A triangle has three
> angles and none of them may be equal to zero, otherwise you just don't have
> a triangle.
>
> What you describe with P0 -> P8 -> P5 -> P0 is a segment of a line not a
> triangle...
>
>
>

no, you are wrong. an angle may have zero degrees, or less than zero
degrees or more than zero degrees.

the sum of the angles in a triangle is 180 degrees. and a 0, 0, 180
triangle is still a triangle.