Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Re: Beyond Golf - reading between the tokens

by theorbtwo (Prior)
on Dec 28, 2002 at 15:15 UTC ( #222735=note: print w/ replies, xml ) Need Help??


in reply to Re: Beyond Golf - reading between the tokens
in thread Beyond Golf - reading between the tokens

I thought of that too, but it does have some problems. Eval-string is very cheap in that accounting. print 'a'.'b'; is cheaper then print 'a','b'; (the former constant-folds to print 'ab';).


Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node).


Comment on Re: Re: Beyond Golf - reading between the tokens
Select or Download Code
Re: Re: Re: Beyond Golf - reading between the tokens
by Juerd (Abbot) on Dec 28, 2002 at 15:40 UTC

    I thought of that too, but it does have some problems. Eval-string is very cheap in that accounting. print 'a'.'b'; is cheaper then print 'a','b'; (the former constant-folds to print 'ab';).

    This is why print "a"."b"; is faster and more efficient than print "a","b";. I think it is *good* to have the former be less points.

    When not using constants, it's a different story: print "a".$_; is 9 concise-lines while print "a",$_; is 8.

    I think eval-string should be avoided anyhow, in a golf contest like this one.

    - Yes, I reinvent wheels.
    
    - Spam: Visit eurotraQ.
    

      Try playing your modified golf game with a program to produce the 100 bottles of beer song. The winner is obvious, but I maintain is more complex from a maintainance perspective than a far shorter dynamic solution.

      All forms of golf raise the question of trying to define what kind of shortness is appropriate. There is no good answer. And the more natural the answer that you try to come up with, the trickier the boundary cases become. There is no good solution.

      PS Stupid trick for regular golf. If side-effects are unspecified, then eval is often more shortly written as s//print"Some code here"/e

        Yah. You've got a point. The best way to judge such a thing may be to have an "impartial" judge decide which one they like best.

        Personaly, I like the idea of the various scored programing contests. Your bottles-of-beer question is simply a bad question. A better one would have read: write a function, bottles_of_beer, which takes a single parameter, the number of bottles to start with. It should return a string of the form "$n bottles of beer on the wall, $n bottles of beer. You take one down, you pass it around...\n$n-1 bottles of beer on the wall"..., where $n is the number passed in. It should end with the line "ENOBEER", after you've passed around the last beer.

        "Winners" will be programs that do it in the fewest number of characters (as mesured by ls -l, on a one-character-newline system), the fewest opcodes (as mesured by B::Concise), and the shortest running time (on my system).

        (In fact, can anybody find issue with this form of rules? I might write up a Tutorial on golf contests... even though I don't purticularly like writing it. (I might like doing perl racing, or minimal-opcode-programing (NEED BETTER NAME!), though.) Hm. Two more scoring methods just crossed my mind: B::Size (more then number of opcodes, since it also includes info on constants), and the size of the output of B::Assemble (more then B::Size, less then B::Size? Different in any way the B::Size? I don't know)

        Anyway, I find the topic very intersting, and am probably going to ponder mroe on it. But now, I'm going to bed.


        Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node).

Re^3: Beyond Golf - reading between the tokens
by Aristotle (Chancellor) on Dec 28, 2002 at 23:09 UTC
    I concur with Juerd - the costs are assesed correctly if you throw non-trivial cases into the equation. As far as eval STRING is concerned, I'm wondering if it shouldn't simply be forbidden.

    Makeshifts last the longest.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (15)
As of 2014-11-26 10:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (167 votes), past polls