Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Perl Golf Ethics

by Anonymous Monk
on Dec 31, 2006 at 10:44 UTC ( #592386=perlquestion: print w/ replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

Currently, I am golfing at the Fonality Golf Challenge http://www.fonality.com/golf. I have an ethics question.

I have found, in the post mortem of a past golf challenge, a solution to that hole that could help me in this current golf. Is it acceptable to use part of that solution?

In general, I would say that since this information is freely available on the web, all players have access to it and it is fair game. In fact, it takes some modification of the original to even fit it into my current solution.

On the other hand, it was very creative and based on the author’s notes took quite some time and effort to create. So, part of me feels a little guilty for using it, especially in this case where there is a potential for financial gain (note: I have no chance of beating the original author in this golf either).

I have not been golfing for very long. So, I ask, what does the Perl and Perl Golfing community think about using portions of previous solutions?

PS: I did a bad thing and posted this anonymously. Not because I wanted to avoid any XP flack, but simply because I am a little embarrassed about asking such a question.

Comment on Perl Golf Ethics
Re: Perl Golf Ethics
by cog (Parson) on Dec 31, 2006 at 11:06 UTC
    I have found, in the post mortem of a past golf challenge, a solution to that hole that could help me in this current golf. Is it acceptable to use part of that solution?

    Why don't you give them your answer and state the fact that you used whatever you did?

    This way you're not fooling anyone, you're showing you have ethics and, something that people quite often miss, you're showing that you can find other solutions that were not created by you.

    It's kind of the same advantage of hiring someone that will always look on Perlmonks to see if someone did the task before, or someone that will always look for an open source project that will solve his problem before trying to solve it him/herself. It's actually a good thing!

Re: Perl Golf Ethics
by rinceWind (Monsignor) on Dec 31, 2006 at 11:19 UTC

    The definitive place to look for answers to questions such as yours, should be the competition rules. As there doesn't seem to be an answer, I suggest sending an email to the address shown for "questions". I don't see why posting or emailing such a question is embarrassing - maybe you'll receive an answer that you don't like. But maybe the clarification would stop somebody else reusing an even better solution out there on the web, that you haven't found yet :).

    Regarding the ethics, I do think that using somebody else's solution or part thereof, is going against the spirit of the competition, much in the same way as internet searches in school exams, or using a chess program to help find your moves against online opponents. On the other hand, if you can rattle off the techniques used in past golf solutions from memory, this is perfectly valid. Having another window open with the prior code in it, is to my mind cheating.

    That's my take on it. I've never run a golf competition; maybe others can comment.

    --

    Oh Lord, won’t you burn me a Knoppix CD ?
    My friends all rate Windows, I must disagree.
    Your powers of persuasion will set them all free,
    So oh Lord, won’t you burn me a Knoppix CD ?
    (Missquoting Janis Joplin)

      I remember a University colleague cheating with an assignment in AI - he had to build an alpha-beta pruning based opponent in connect4. He lingered until the very end, and then resorted to the Internet (and 10 years ago I don't remember Google :). He later commented: "0 in AI... but 10 in websurfing!".

      It's interesting that you cite the chess game. There are a lot of books on chess, and many openings have been studied and are learnt by a lot of people. What would you think about someone reviewing his chess book while doing an online (e.g. play-by-mail) match? I'm not sure I'd reduce it all to "take it only from your memory", even if I've to admit that I don't really know where to draw the line.

      Flavio
      perl -ple'$_=reverse' <<<ti.xittelop@oivalf

      Don't fool yourself.

        With online chess, the rules are usually given on the site. For non real time chess, such as correspondence chess (e.g. http://www.redhotpawn.com) consulting opening books or chess opening websites is allowed, but feeding your moves or position to a chess program is not allowed, though they can't stop you, and it's difficult to prove it.

        The site I mentioned has forums where this subject has been discussed in great depth.

        --

        Oh Lord, won’t you burn me a Knoppix CD ?
        My friends all rate Windows, I must disagree.
        Your powers of persuasion will set them all free,
        So oh Lord, won’t you burn me a Knoppix CD ?
        (Missquoting Janis Joplin)

Re: Perl Golf Ethics
by ysth (Canon) on Dec 31, 2006 at 11:32 UTC
    Golf involves many tricks that you can learn from others; go for it!
Re: Perl Golf Ethics
by rodion (Chaplain) on Dec 31, 2006 at 12:23 UTC
    Golf is a discipline with an artificial goal, set up to provide competition among its participants, with explicit rules for the competition.

    Software is a discipline with practical goals, often accomplished through cooperation of its participants, who have to tinker with the rules of cooperation and competition along the way.

    While both involve ethics, intelligence and cleverness in some form, the forms these abilities take in each discipline is quite different. I believe it would be a major dis-service to the cooperative spirit of programming communities, perlmonks especially, to apply the ethical lessons from golf to our sphere, even under the guise of an analogy. It subtly undermines the cooperation, and confuses the ethical questions, and good cooperation and clear ethics are both of them hard to establish and maintain.

    It is probably just as bad to reason from software to golf, but I'll leave golfers to comment on that, preferably in a golfing forum.

Re: Perl Golf Ethics
by shmem (Canon) on Dec 31, 2006 at 13:18 UTC
    Your ethics are yours; if it's ok for you to use prior art, go for it. The final decision lies in the hands of fonality. They surely also have The Golf Book, and they may accept or reject your solution.

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
Re: Perl Golf Ethics
by ww (Bishop) on Dec 31, 2006 at 13:47 UTC
    IMO, sounds like using it, with attribution as suggested above, is just fine.

    But, at the risk of a bit too much pop psychology, does the fact you felt the need to post annonymously hint at ethical reservations on your part? (If so, perhaps these answers will help allay or even resolve them.)

    However, if the embarrassment you felt is merely at some sense of ignorance then I see no need for it. What's the most used area here? SOPW. We share our ignorance in the OPs there... to our mutual benefit.

    ...and good luck, in any case, on the challenge!

Re: Perl Golf Ethics
by throop (Chaplain) on Dec 31, 2006 at 14:16 UTC
    Anonymous Brother

    Let us ask ourselves, "Why is Fonality sponsoring this tourney?" In their rules, they ask that entrants be willing to talk to one of their recruiters. Clearly, they hope to hire some good Perl talent from the competition.

    Ask yourself what Fonality would want from an employee in a similar situation. Suppose you were a Fonality manager and you asked a new hire to code a solution to a problem. If that employee knew that there was code on the web that (with minor modification) would solve the problem, would you want him to

    • Eschew the solution because he hadn't written it out of his own cleverness?
    • Use the solution, crediting the author?
    • Use the solution and make no reference to the source of the approach?
    throop
Re: Perl Golf Ethics
by thospel (Hermit) on Dec 31, 2006 at 16:46 UTC
    In the perl golf community it is in fact expected that golfers learn from solutions to previous golfs. Many of the standard tricks of the trade have not been invented by the people using them.

    If it turns out that some specific but not generally known piece of knowledge helps enormously in a golf, it is the habit to inform the party holding the golf so they can decide if they want to add it to the challenge notes. That way everyone may play on a more level field.

    I have already told fonality about an existing golf that helps a lot, but I forgot to suggest a link to it on the rules page.

      I didn't realize that there was a "perl golf community", or that being part of said community was worth cash.

      It leaves a very bad taste in my mouth that this contest was effectively written for a few people who were in the know, who had seen your magic algorithm, shutting out the rest of us.

        Well, I imagine there are a lot of communities where being part of that community is worth cash.

        There was a cash-paying competition for Perl. Let's agree that more cash for Perl knowledge is a good thing, even if the methods in this case may not meet your standards.

        --Solo

        --
        You said you wanted to be around when I made a mistake; well, this could be it, sweetheart.
        I agree that this was very unfortunate, but let's not try to read too much into it.

        From an email exchange I know that the organizers didn't know about that particular very relevant historical golf, so it certainly wasn't intentional. I'm quite sure they would not have chosen this challenge if they had known.

        The link to the relevant code was in shmems post in this very thread. You being part of the perlmonks community made that information available to you too.

        As the other solutions in that historical golf show, not hitting on the magic method doesn't loose a good golfer more than (order of magnitude) 5 strokes. This might indeed be enough to pass a few people on the scoreboard, but it's in fact less than the average distance between players.

        Ton's brilliant magic formula won the original roman tournament by only three strokes. It is also worth noting from the fonality golf post mortem that TedYoung (presumably a first time golfer) produced a score of 116.50 before finding Ton's magic formula ... and that a score of 169.51 was enough to win a prize. Also, Jasper, who is part of the Perl golf community, "forgot" about Ton's magic formula, yet was still able to finish in ninth place with a score of 125.

        So not knowing this formula did not "shut out" people from winning a prize. Moreover, searching for perl golf (via google and/or SuperSearch) would have uncovered the original perl golf roman numerals game easily enough (as Ted Young did).

        Perhaps the rules should have been clarified to state, as Ton says, that golfers are expected to research and learn from prior art and that it is not cheating to do so.

        In summary, I do not blame Fonality for this and, despite the prior roman art, the wide range of scores and creative approaches showed that there was a lot of golf played in this competition outside the magic formula.

        To do well at Perl golf, perhaps the most important thing is to unearth the "fundamental insights" into the problem. Some of the fundamental insights of this golf were:

        • Rather than calculating a running total, it's shorter and simpler to convert $_ in place; for example, transform II plus III into 2 + 3. With that done, simply use eval to compute the total.
        • The y/IVXLC/XLCDM/ transliteration is a short and sneaky way to multiply by ten.
        • You don't need to write two converters: it is sufficient to write an arabic_to_roman() converter. To convert the other way, simply convert 1..3999 into a table or something and do a lookup. I didn't appreciate this at first and foolishly wrote two converters. When I became aware of my blunderific overlook, my score dropped by 40 strokes.
        • The shortest way to lookup the number corresponding to a roman numeral is to create a symbolic reference for each roman numeral whose value is the corresponding arabic number. For more fun, a la ton and others, transform, for example, II plus III into $II  +$  III and eval that. This is the insight I missed, only trying a hash and a grep lookup.
        • You can further eliminate the array of roman numerals by creating a second set of symbolic references mapping negative numbers to roman numerals. Note that for this to work you must use negative numbers, since positive ones (e.g. $3) are read-only variables used by perl's regex engine. As you might expect, not many of the contestants hit upon this final insight, only ton, Juho, and jojo managing it.
        Notice that none of these insights depends on knowing Ton's magic formula. Golfers like Ton have a knack for finding these insights quickly and easily, while I struggle; once I find them, it is a simple matter of golfing technique to whittle down the solution. For me, the hard part is to find them. Using the above insights, a simple solution like this:
        #!perl -pl map{$_.=(!y/IVXLC/XLCDM/,I,II,III,IV,V,VI,VII,VIII,IX)[$&]while s/\d// +;$$_=$n++}@R=0..3999; y/mp/-+/;s/\w+/${$&}/g;$_=$R[eval]
        comes in at around 130. You could get down to around 120, again without knowing Ton's magic formula, by whittling the arabic-to-roman converter:
        #!perl -pl map{y/IVXLC/XLCDM//s//$&-9?$&-4?I x$&:IV:IX/e&s/I{5}/V/while/\d/;$$_=$ +n++}@R=0..3999; y/m/-/;s/\w+/+${$&}/g;$_=$R[eval]
        To go lower, you'll need to sneak in y/iul-}/-$+ / somewhere to transform $_ directly into symrefs (e.g. $II  +$  III) that can be directly eval'ed. Doing that allows you to eliminate the s/\w+/${$&}/g above. Still further savings are available by replacing the @R array above with a second set of symbolic references, this time mapping negative numbers back to roman numerals.

        While I don't fully understand your shortest 186 solution:

        #!perl -pla %n=I1V5X10L50C100D500M1000=~/(.)(\d+)/g;sub d{$#_-=$z*2*(@_&&$z<$_)-($z=$_)for@n{/./g};@_}$t+=($.=/p/-/n/||$.)*d for@F;map{$s.=$_ x($t/d),$t%=d}M,CM,D,CD,C,XC,L,XL,X,IX,V,IV,I;$_=$s
        it seems like sour grapes to claim that:
        this contest was effectively written for a few people who were in the know, who had seen your magic algorithm, shutting out the rest of us.
        As shown above, without knowing Ton's magic algorithm, you could have easily trimmed 60 strokes off your solution by unearthing the fundamental insights into the problem.

        Update: oops, changed 4e3 to 3999 (4e3 fails test case "MD plus I") plus minor code improvements. Added extra symbolic reference insight.

Re: Perl Golf Ethics
by TedYoung (Deacon) on Dec 31, 2006 at 17:34 UTC

    Thank you for the replies everyone.

    Looking back, I think my choice of the word “Ethical” was poor. Really this is about perl golf rules and standards, not ethics.

    Again, I posted anonymously because I suspected the answer to my question was considered obvious; something that every golfer just knows. But, from my point of view, it could have easily been either “obviously yes” or “obviously no”. :-) As always, the monastery continues to be gentle to those still learning.

    And thanks ton, it looks like you have already thought of this. As always your 10.54 steps ahead of me! You are an amazing golfer, and your 17 point submission had me climbing the walls. Even through it was rejected, when this is all over, I have to see what you posted.

    Back to the battle grounds!

    Ted Young

    ($$<<$$=>$$<=>$$<=$$>>$$) always returns 1. :-)
      Whoever posted 17 stroke solutions wasn't me.
Whitespace in Perl Golf
by petdance (Parson) on Jan 01, 2007 at 04:54 UTC
    Also note that the scoring program doesn't count trailing whitespace each line. There's a lot of encoding that can be done with whitespace. See Acme::Bleach.

    xoxo,
    Andy

      You can do that, but such solutions should be rejected. The rules do not say that trailing whitespace doesn't count.

      The removal of trailing whitespace in the test programs was intentionally added during the TPR golfs because it turned out that people have the unfortunate habit of using editors where it's not very visible that they have extra trailing newlines, and where they had the winning solution without realizing it. And then these people wasted days trying to still improve their solution. Solving this problem of serious players was decided to be more important than stopping jokers playing games with trailing whitespace.

      If people seriously think this is a problem I could change the way this case is handled in the generic test program skeleton. But currently I don't considere this well known abuse to be relevant enough for that.

        I would prefer that trailing whitespace WOULD be counted, and people should be smart enough to remove. Shlomi found a solution where any given program can be compressed into whitespace, a la Acme::Bleach, with a 25-byte decoder.

        Let's just make it explicit.

        xoxo,
        Andy

        such solutions should be rejected. The rules do not say that trailing whitespace doesn't count.
        Nor do they specify how scoring is done, other than by giving you a means to calculate your score. How can a score calculated for you then be rejected as a rule violation?

        Update: thospel is correct; I looked for such a rule and somehow managed to miss it. So never mind.

Re: Perl Golf Ethics
by syphilis (Canon) on Jan 01, 2007 at 11:52 UTC
    Seems to me that both "Perl Golf" and the other form of "Golf" (where one hits a ball with a stick ... and the ball's not even moving ... how easy is that !!) are, indeed, governed by the same ethical consideration - namely:

    If the rules do not prohibit it, then it's ethical.

    That is surely "ethics" at it's most fundamental.

    Cheers,
    Rob
      If the rules do not prohibit it, then it's ethical.

      Heh. Exactly the opposite of firewall ruleset logic, where anything not expressly permitted is verboten by default.


      Sanity? Oh, yeah, I've got all kinds of sanity. In fact, I've developed whole new kinds of sanity. You can just call me "Mister Sanity". Why, I've got so much sanity it's driving me crazy.
Re: Perl Golf Ethics
by ambrus (Abbot) on Jan 01, 2007 at 16:49 UTC

    I searched a lot with google because I suspected that roman number conversion is such an obvious topic that there had to be another perl golf competition about it. I didn't find anything, but if I did, I would have tried to use it in my golf solution. Thus, I think it is within the rules.

        Thanks, I've already found it. In fact shmem has linked to The Golf Book that contains the solution in this very thread.

        As it turns out, 10 out of 12 of the golfers that ended up above me in the final leader-board have used one of the two magic formulas of ton.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://592386]
Approved by Joost
Front-paged by ww
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: (10)
As of 2014-07-23 06:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (135 votes), past polls