Re: Guess what ... a new minigolf just started
In article <[EMAIL PROTECTED]>, Shlomi Fish <[EMAIL PROTECTED]> writes: > In any case, there's an exploitable "feature" in the count sub-routine in the > testsuite: > > <<< > sub count { > my ($hole, $tie) = @_; > local $_ = slurp($props{$hole}{work}, $binary); > if (/^\#!/) { > s/^\#![\t ]?\S+// && s/\n//; > } > s/\s*\z//; < > my $md5 = md5_hex($_); > my $score = length; > my $normal= $score ? y/ -~\t\n// / $score : 1; > if (defined($tie)) { > defined(my $code = $tie_map{lc($tie)}) || > die "Unknown tie function $tie\n"; > $score += $code->($_, $score)/$nr_ties if $score; > $ties++; > } > return ($score, $md5, $normal*100); > } > > > What happens is that trailing whitespace is removed. But one can use it to > encode the entire program, no matter how long it is, and get a 25 characters > solution. In fact the space removal code is there intentionally because in previous golfs people actually had programs counted with extra chars because they forgot to remove trailing newlines/spaces (which can be hard to spot in some editors). This was considered unfair to these players and on popular request I added the space stripping. Nobody said that what the test program says is your official score, just as passing the tests doen't make your program officially correct. The generic rules at http://www.xs4all.nl/~thospel/golf/rules.html is where scoring is defined for most minigolfs, and they define the score as total number of bytes, and then it's clear all these end spaces count. So if someone submits a program that uses end spaces to encode the solution, simply smile at him and put him at a score that is his total byte length. I could make a patch for the gentester, but I think it would cause more problems than it solves.
Re: Guess what ... a new minigolf just started
On Fri, Sep 09, 2005 at 20:34 +0200, Stefan `Sec` Zehl wrote: > On Fri, Sep 09, 2005 at 13:39 +0300, Shlomi Fish wrote: > > Regards, > > > > Shlomi Fish (who would now be working hard on optimizing his > > relatively long solution) > > It took me quite some time to reach you, but after spending some more > hours playing around, I finally found the trick for a shorter solution, > after which I was able to shed 20 more characters quickly. > > Lets see if anyone can top the 37 ;) Awww. I'm sooo stupid. After seeing the post-mortem, i realize that I actually had the 36 char version in my editor at one point, I just didn't notice it, because I thought it was still 37 chars %). I must remember to run each and every version through the test script. CU, Sec -- At least in Norway, I know people have been put in jail for following the prime directive instead of helping. -- <[EMAIL PROTECTED]>
Re: Guess what ... a new minigolf just started
On Fri, Sep 09, 2005 at 13:39 +0300, Shlomi Fish wrote: > Regards, > > Shlomi Fish (who would now be working hard on optimizing his > relatively long solution) It took me quite some time to reach you, but after spending some more hours playing around, I finally found the trick for a shorter solution, after which I was able to shed 20 more characters quickly. Lets see if anyone can top the 37 ;) CU, Sec -- "There was a clothing company there called OpenBSD, later somebody told me they make an operating system as well." -- Poul-Henning Kamp's EuroBSD Conference review.
Re: Guess what ... a new minigolf just started
On Friday 09 September 2005 10:15, Terje Kristensen wrote: > Yep, your eyes does not deceive you. We have actually started a new golf > here at http://terje2.perlgolf.org > > I hope there still is some perl golfers out there itching for a new > challenge. > > The task this time is called "beads". > > Terje and Mtve Thanks for the new golf! In any case, there's an exploitable "feature" in the count sub-routine in the testsuite: <<< sub count { my ($hole, $tie) = @_; local $_ = slurp($props{$hole}{work}, $binary); if (/^\#!/) { s/^\#![\t ]?\S+// && s/\n//; } s/\s*\z//; < my $md5 = md5_hex($_); my $score = length; my $normal = $score ? y/ -~\t\n// / $score : 1; if (defined($tie)) { defined(my $code = $tie_map{lc($tie)}) || die "Unknown tie function $tie\n"; $score += $code->($_, $score)/$nr_ties if $score; $ties++; } return ($score, $md5, $normal*100); } >>> What happens is that trailing whitespace is removed. But one can use it to encode the entire program, no matter how long it is, and get a 25 characters solution. Like this: <<< #!/usr/bin/perl use strict; use warnings; use IO::All; my @code = io("beads.pl")->getlines(); my $bleach = join("", unpack("b*", ";$code[1]")); $bleach =~ s!0! !g; $bleach =~ s!1!\t!g; io("bleach/beads.pl")->print( qq{open 0;eval pack"ab*",<0>\n$bleach} ); >>> This is not my original idea: Piotr Fusik used it for his solution in the last kernelpanic.pl Perl golf. But I suggest issuing a new beadstest.pl file so that people won't all submit 25-characters solutions and this would be more of a real golf. It should be noted in the subsequent golfs as well. Regards, Shlomi Fish (who would now be working hard on optimizing his relatively long solution) - Shlomi Fish [EMAIL PROTECTED] Homepage:http://www.shlomifish.org/ 95% of the programmers consider 95% of the code they did not write, in the bottom 5%.