Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: (Efficiency Golf) Triangular numbers

by blakem (Monsignor)
on May 31, 2001 at 10:30 UTC ( [id://84475]=note: print w/replies, xml ) Need Help??


in reply to (Efficiency Golf) Triangular numbers

This was a fun one. My solution looks quite similiar to Abigail's in structure, but is not nearly so elegant.

I question how they are really going to judge these based on execution time. Its basically a "find the needle in a haystack" problem, but after you've found it, its pretty easy to write a program that finds it faster the next time around.

For instance: Which one of these wins? Are any thrown out for "cheating"?

1: Brute force, try every concievable set of four numbers (loooong time)

2: Using some sort of filtering at each stage, so not every set of four is used (much quicker)

3: Cleverly ordering the stages, so they are done in an optimum order -- perhaps 'THREE->TEN->ONE->SIX'. (slightly quicker, though is uses information gathered in program 2)

4: Brute force, but coded so that the first set of four you try is the correct answer. (even faster!!!)

5: print "$answer"; (clearly the fastest)

Since there is only one haystack and one needle, how do you determine which program "finds" it, and which has already been told where it is....

-Blake

Replies are listed 'Best First'.
Re: Re: (Efficiency Golf) Triangular numbers
by blakem (Monsignor) on May 31, 2001 at 12:02 UTC
    Thanks for the efficiency clarification... (i.e. only counts here, not for the magazine prize) I was about to add some "pre-sorting" to my arrays, allowing the answer to magically be the first one I tried.

    -Blake

Re: Re: (Efficiency Golf) Triangular numbers
by tachyon (Chancellor) on May 31, 2001 at 14:22 UTC

    'Cleverly' ordering the stages is the approcah I used. See the code I have just posted

    tachyon

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://84475]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-03-19 02:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found