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%.