Challenge: Triangles puzzle

?

=?ISO-8859-1?Q?Jens_Axel_S=F8gaard?=

Dirk said:
Nope. Anything that's comparable will do for the simple solution,
and with two additional lines, you can use anything that only admits equality.
If you just want the number of solutions, and not the solutions themselves
without "duplicates" by permutation, then you can do even without that
(just divide the length of the list of solutions by 6).

BTW, one more important difference is that some algorithms just counted,
while some actually computed all solutions. Some algorithms restricted
themselves to two "fans" of lines, while some allowed an arbitrary
geometry. And so on, and so on.

It is also interesting to look at the various time complexities for
the algorithms used. The programs that generate all tree-tuples of points
and then filter for triangles and remove duplicates will be slower than
programs that generate the triangles in way that doesn't generate non-triangles
nor duplicates, when we run the programs for large n and m.
 
G

Gareth McCaughan

Dirk Thierbach wrote:

[I said:]
No, at least one short solution did count those assignments (3 lines
of assignments out of 6 total lines of code).

I beg your pardon; I misremembered.
You could replace those 3 lines by 1 line to read the contents of a file,
1 line to parse it and to call the algorithm, 1 line to calculate the
missing part of the input definition, and 1 line to print the result.
Maybe an additional line to get the filename from the commandline arguments.
So instead of 3, you have 4-5 lines. I didn't bother, because then you have
to edit 2 files instead of 1 for testing.
Sure.


Nope. Anything that's comparable will do for the simple solution,
and with two additional lines, you can use anything that only admits equality.

I'm not sure how we're in disagreement here...
If you just want the number of solutions, and not the solutions themselves
without "duplicates" by permutation, then you can do even without that
(just divide the length of the list of solutions by 6).

Indeed. (Though you may, in some implementations, need a little
extra code to avoid repeated points.)
BTW, one more important difference is that some algorithms just counted,
while some actually computed all solutions. Some algorithms restricted
themselves to two "fans" of lines, while some allowed an arbitrary
geometry. And so on, and so on.

Indeed. The solution that was a 3-character program in J
(or whatever it was) was particularly notable in this respect :).

(I get the impression that you think I think it was cheating
to avoid using a separate file for the data. I don't.)
 
D

Dirk Thierbach

Indeed. The solution that was a 3-character program in J
(or whatever it was) was particularly notable in this respect :).

Yes. J (and APL, and K) can be very terse, but also somewhat hard to
read (at least for me).
(I get the impression that you think I think it was cheating
to avoid using a separate file for the data.

No. I guess the point was that other differences are much more important.

- Dirk
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top