Re: YN golf
On Mar 31, 2008, at 6:54 PM, Philippe Bruhat (BooK) wrote: On Mon, Mar 31, 2008 at 04:34:58PM -0700, Rick Klement wrote: perl -le 'print for glob"{Y,N}"x5' Of course you have to run this in a directory that doesn't contain any file matching /^[YN]{5}$/. Not true. The {} notation doesn't care whether files of that name actual exist. I tested like so on Mac: % touch Y % perl -le 'print for glob"{Y,N}"x5' Y N YYYNY YYYNN YYNYY YYNYN YYNNY YYNNN YNYYY YNYYN YNYNY YNYNN YNNYY YNNYN YNNNY Y N NYYYN NYYNY NYYNN NYNYY NYNYN NYNNY NYNNN NNYYY NNYYN NNYNY NNYNN NNNYY NNNYN Y N
Re: regex of the month (decade?)
On Jan 11, 2008, at 8:01 AM, David Landgren wrote: The benchmark may be flawed, since my appreciation of Unicode is little more than "things went downhill after 7-bit ASCII". Haven't I read that you live in Paris? I figured that anyone who lives in a country whose dominant language was not fully expressible in ASCII would love Unicode. On a major tangent, have others noticed the resurgence of the umlaut in printed English? I keep seeing things like coöperation or coördinates -- particularly in Technology Review, but in other publications on occasion too. Is that because it's *supposed* to be spelled that way, but ASCII and the typewriter have suppressed that spelling for my lifetime? Chris
Re: Fun with Boggle
On Dec 6, 2007, at 11:44 AM, Brad Greenlee wrote: I haven't written any Perl for fun in a while, but I recently entertained myself a bit by writing a Boggle puzzle solver in Ruby: http://blog.footle.org/2007/12/05/cheating-for-fun/ I'm not sure if this particular puzzle has come up before in FWP, but I was curious as to how closely this yak could be shaved in Perl. I suspect Ton could do it in somewhere around 40 characters. Anyone interested? Brad Attached is my version coded in Perl which produces identical output. I employed a shortcutting algorithm that resulted in a 77x speedup over your Ruby implementation using the same word dictionary. My algorithm stops looking when the current prefix matches no known word. However, my code is 33% longer, counting lines. I think those extra 30 lines are worth saving 7.5 minutes of execution time. % time perl boggler.pl lyltonzigororwho > boggler.pl.out 4.383u 0.275s 0:06.46 71.9% 0+0k 0+0io 0pf+0w % time ruby boggler.rb lyltonzigororwho > boggler.rb.out 340.764u 5.144s 7:45.79 74.2% 0+0k 0+4io 0pf+0w % diff boggler.pl.out boggler.rb.out Chris #!/usr/bin/perl -w use strict; use List::MoreUtils qw(uniq); my $MIN_LETTERS = 3; my $MAX_LETTERS = 12; my @POINTS = (0,0,0,1,2,4,6,9,12, (16)x($MAX_LETTERS-8)); # no idea what the scoring should really be main(); exit 0; sub main { my $board_letters = shift @ARGV or syntax(); my @board = init_board(lc $board_letters); my ($words, $nwords) = load_words(); print "loaded $nwords words. solving '$board_letters'...\n"; my @found; for my $i (0..$#board) { push @found, walk_board([EMAIL PROTECTED], $i, $words); } @found = uniq @found; my $score = 0; for my $word (@found) { print "found word: $word\n"; $score += $POINTS[length $word]; } print 'found ', scalar @found, " words\n"; print "total score: $score\n"; } sub syntax { die <<"SYNTAX"; Usage: boggler.pl where the board string is all the letters on the board, from left to right and top to bottom. Example: given the board: LYLT ONZI GORO RWHO the board string would be: lyltonzigororwho (case is ignored) the letter 'q' will automatically have a 'u' appended SYNTAX } sub load_words { my $words = {}; open my $fh, '<', 'words' or die 'Failed to read file "words"'; my $nwords = 0; my $nlines = 0; while (my $line = <$fh>) { ++$nlines; # Remember that line length includes \n my $wordlength = -1 + length $line; next if $line =~ m/q[^u]/xms; # reject impossible Boggle word $line =~ s/qu/q/gxms; next if $MIN_LETTERS > $wordlength; next if $MAX_LETTERS < $wordlength; my $hash = $words; for my $letter ($line =~ m/(.)/gxms) { $hash = $hash->{$letter} ||= {}; } ++$nwords; } close $fh; #print "Loaded $nwords words, rejected @{[$nlines-$nwords]} words\n"; return ($words, $nlines); } sub init_board { my ($board_letters) = @_; my $board_size = int(0.5 + sqrt length $board_letters); if ($board_size * $board_size != length $board_letters) { die "Board is not square! ($board_size x $board_size != @{[length $board_letters]})\n"; } my @board = map { { letter => $_, moves => [], seen => undef } } $board_letters =~ m/(.)/gxms; for my $i (0 .. $board_size - 1) { for my $j (0 .. $board_size - 1) { my $pos = $i + $j * $board_size; # Are we at any edges/corners? my $i0 = $i > 0; my $in = $i < $board_size -1; my $j0 = $j > 0; my $jn = $j < $board_size -1; push @{$board[$pos]->{moves}}, $pos + 1 if $in; push @{$board[$pos]->{moves}}, $pos + $board_size + 1 if $jn && $in; push @{$board[$pos]->{moves}}, $pos + $board_size if $jn; push @{$board[$pos]->{moves}}, $pos + $board_size - 1 if $jn && $i0; push @{$board[$pos]->{moves}}, $pos - 1 if $i0; push @{$board[$pos]->{moves}}, $pos - $board_size - 1 if $j0 && $i0; push @{$board[$pos]->{moves}}, $pos - $board_size if $j0; push @{$board[$pos]->{moves}}, $pos - $board_size + 1 if $j0 && $in; } } return @board; } sub walk_board { my ($board, $pos, $words, @letters) = @_; my $here = $board->[$pos]; return if $here->{seen}; my @found; my $nextword = $words->{$here->{letter}}; if ($nextword) { if ($nextword->{"\n"}) { push @found, join q{}, @letters, $here->{letter}; } if (@letters < $MAX_LETTERS) { $here->{seen} = 1; for my $nextpos (@{$here->{moves}}) { push @found, walk_board($board, $nextpos, $nextword, @letters, $here->{letter}); } $here->{seen} = undef; } } return @found; }
Re: Punctuation Free Quine -- Almost
On Sep 19, 2006, at 6:12 AM, Bart Lateur wrote: open 0 and print readline 0 That's very cool! But, according to the Wikipedia definition it's not a quine: "Note that programs which take input are not considered quines." -- http://en.wikipedia.org/wiki/Quine Chris -- Chris Dolan, Software Developer, Clotho Advanced Media Inc. 608-294-7900, fax 294-7025, 1435 E Main St, Madison WI 53703 vCard: http://www.chrisdolan.net/ChrisDolan.vcf Clotho Advanced Media, Inc. - Creators of MediaLandscape Software (http://www.media-landscape.com/) and partners in the revolutionary Croquet project (http://www.opencroquet.org/)
Re: local vs. my (was Re: code line of the day)
On Sep 9, 2006, at 3:12 AM, A. Pagaltzis wrote: * Chris Dolan <[EMAIL PROTECTED]> [2006-09-09 03:55]: Works the same. I often use `local $_` in tiny functions that mangle just a single value. Matter of taste/style. Ahh, I see -- cargo cult. ;-) Err, what? I chose that style for myself. I didn’t pick it up from anyone else and certainly not unthinkingly. I didn't mean that to be insulting -- I was just teasing. In fact I usually respect your contributions a lot, so I was curious why your style was different from mine and if there was a reason why yours might be better. I just benchmarked the two versions, and "my" wins by a wide margin: % perl test.pl Rate localmy local 467290/s-- -33% my699301/s 50%-- I dunno if that was supposed to be an argument, but I couldn’t care less. I hope I don’t have to explain why as well. That was for my curiosity and to convince me, not to convince you. That's why I changed the subject line in the message. I apologize for my less-than-clear motives. Chris -- Chris Dolan, Software Developer, Clotho Advanced Media Inc. 608-294-7900, fax 294-7025, 1435 E Main St, Madison WI 53703 vCard: http://www.chrisdolan.net/ChrisDolan.vcf Clotho Advanced Media, Inc. - Creators of MediaLandscape Software (http://www.media-landscape.com/) and partners in the revolutionary Croquet project (http://www.opencroquet.org/)
local vs. my (was Re: code line of the day)
On Sep 8, 2006, at 6:48 PM, A. Pagaltzis wrote: * Chris Dolan <[EMAIL PROTECTED]> [2006-09-08 17:10]: Why did you use "local"? Shouldn't the following work? sub flatten_copy { my $s = shift; ref $s eq 'SCALAR' ? "$$s" : "$s"; } Works the same. I often use `local $_` in tiny functions that mangle just a single value. Matter of taste/style. Ahh, I see -- cargo cult. ;-) Changing the topic a little bit... I've always suspected there was a speed difference between local and my. So, I just benchmarked the two versions, and "my" wins by a wide margin: % perl test.pl Rate localmy local 467290/s-- -33% my699301/s 50%-- % perl -v This is perl, v5.8.6 built for darwin-thread-multi-2level (with 2 registered patches, see perl -V for more detail) = test.pl == #!/usr/bin/perl -w use strict; use Benchmark qw(cmpthese); my $s = 'foo'; $_ = 'foo'; cmpthese(1_000_000, { 'local' => sub { flatten_copy_local('bar'); }, 'my' => sub { flatten_copy_my('bar'); }, }); sub flatten_copy_local { local $_ = shift; ref $_ eq 'SCALAR' ? "$$_" : "$_"; } sub flatten_copy_my { my $s = shift; ref $s eq 'SCALAR' ? "$$s" : "$s"; } -- Chris Dolan, Software Developer, Clotho Advanced Media Inc. 608-294-7900, fax 294-7025, 1435 E Main St, Madison WI 53703 vCard: http://www.chrisdolan.net/ChrisDolan.vcf Clotho Advanced Media, Inc. - Creators of MediaLandscape Software (http://www.media-landscape.com/) and partners in the revolutionary Croquet project (http://www.opencroquet.org/)
Re: code line of the day
On Sep 8, 2006, at 9:42 AM, A. Pagaltzis wrote: [ ... ] sub flatten_copy { local $_ = shift; ref $_ eq 'SCALAR' ? "$$_" : "$_"; } my $t = $self->{templates}; @{$t}{ keys %$tmpls } = map \( flatten_copy $_ ), values %$tmpls; I think I like that. Why did you use "local"? Shouldn't the following work? sub flatten_copy { my $s = shift; ref $s eq 'SCALAR' ? "$$s" : "$s"; } Chris -- Chris Dolan, Software Developer, Clotho Advanced Media Inc. 608-294-7900, fax 294-7025, 1435 E Main St, Madison WI 53703 vCard: http://www.chrisdolan.net/ChrisDolan.vcf Clotho Advanced Media, Inc. - Creators of MediaLandscape Software (http://www.media-landscape.com/) and partners in the revolutionary Croquet project (http://www.opencroquet.org/)
Re: swapping two numbers
On Jun 23, 2006, at 5:01 PM, David Westbrook wrote: Michael R. Wolf wrote: not in-place cause it's 3 lines, but does not use an external temporay value, and should be language-independent: x = x + y y = x - y x = x - y (IIRC my high school BASIC teacher taught us that) This works: $a -= $b = ($a += $b) - $b; Chris -- Chris Dolan, Software Developer, http://www.chrisdolan.net/ Public key: http://www.chrisdolan.net/public.key vCard: http://www.chrisdolan.net/ChrisDolan.vcf
Re: /$sudoku/
On Apr 21, 2006, at 9:51 AM, Steven W. Orr wrote: Interesting. I would expect that rotating a sudoku matrix would not have any impact in the difficulty of the problem. I remember from my old numerical analysis course (back before you young whippersnappers were born) we looked at something called the Hubbard or Hibbard constant for a matrix. The deal was that if you multiplied a matrix by its inverse, then there was something you would come up with that would tell you how hard it was to invert the matrix. Of course you needed the inverse to calculate it in the first place... It's not the asymmetry of the problem that is at fault, but the asymmetry of the solution. The regexp is a brute force, short- cutting solver that works from L->R and T->B. That particular problem simply tickles the worst-case of the regexp, so it's brute forcing its way through a LOT of wrong solutions before hitting on the right one. Chris -- Chris Dolan, Software Developer, Clotho Advanced Media Inc. 608-294-7900, fax 294-7025, 1435 E Main St, Madison WI 53703 vCard: http://www.chrisdolan.net/ChrisDolan.vcf Clotho Advanced Media, Inc. - Creators of MediaLandscape Software (http://www.media-landscape.com/) and partners in the revolutionary Croquet project (http://www.opencroquet.org/)
Re: "Secret" operators
On Feb 2, 2005, at 2:36 PM, Sébastien Aperghis-Tramoni wrote: Hey Philippe, why don't you give the name we found for @{[]} ? It looks like a guy lying on his side in a straightjacket to me. Chris -- Chris Dolan, Software Developer, www.chrisdolan.net Public key: http://www.chrisdolan.net/public.key PGP.sig Description: This is a digitally signed message part
Re: crashing on the full moon
On Jan 12, 2005, at 3:53 PM, Yitzchak Scott-Thoennes wrote: On Fri, Jan 07, 2005 at 06:59:35PM -0800, Josh Goldberg wrote: A (java programming) coworker presented this challenge while discussing a hypothetical situation: * Chris troubleshoots and sees that David (in a moment of sheer insanity) coded the site to crash at 5:42pm on every full moon (do I hear a Perl Monger side say there is a Perl library for just such a thing -- and it's only 2 lines?). Acme::Apache::Werewolf is probably something like what he wants. Haha! Sweet, I like the embedded lyrics in that module. Here's a solution in one line: use Astro::MoonPhase;gmtime=~/17:42:/&&abs((phase time)[2])<1&¨ Chris -- Chris Dolan, Software Developer, www.chrisdolan.net Public key: http://www.chrisdolan.net/public.key PGP.sig Description: This is a digitally signed message part
Re: Load-Bearing Warnings
On Aug 3, 2004, at 1:12 PM, Smylers wrote: I turned warnings off in a script[*0] but made no other changes to it. This broke the script, in that it would no longer run correctly[*1]. ... can anybody guess how it's done? How about: if (!$^W) { die; } :-) Chris -- Chris Dolan, Software Developer, Clotho Advanced Media Inc. 608-294-7900, 313 W Beltline Hwy Suite 41, Madison WI 53713
Re: simple rpn desktop calculator
A simplified version and an equivalent, first-draft Golfed version: #!/usr/bin/perl -w use Math::RPN; $| = 1; while ($_="@ARGV" || <>) { @stack = rpn @stack, split; last if @stack && $stack[-1] =~ /^q/i; print "@stack "; print("\n"),last if @ARGV; } #!perl use Math::RPN;$|=1;1while($_="@ARGV"||<>)&&!((@[EMAIL PROTECTED],split)&&$s[-1]=~/^q/ i||print("@s ")&&@ARGV&&print($/)) Chris On Thursday, August 14, 2003, at 07:52 AM, Bennett Todd wrote: I love this list. Jonathan Paton mentioned Math::RPN; I hadn't heard about that one. My favourite little handy rpn desktop calculator just got a whole lot simpler: #!/usr/bin/perl -w use Math::RPN; if (@ARGV) { print for rpn map { split } @ARGV; print "\n"; exit 0; } $| = 1; my @stack; while (<>) { @stack = rpn(@stack, split); exit 0 if @stack and $stack[-1] =~ /^q/i; print "@stack "; } -Bennett [EMAIL PROTECTED](P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H* -- Chris Dolan, Software Developer, Clotho Advanced Media Inc. [EMAIL PROTECTED], 294-7900, 211 S Paterson, Madison WI 53703
Re: limit the list
A. Pagaltzis wrote: > * Dave Arnold <[EMAIL PROTECTED]> [2002-11-21 02:45]: > >>$str = join ', ', @names; >>if ( length($str) > 90 ) >>{ >> substr($str,rindex($str,",",90)) = ", etc."; >>} > > > Nice, and so obvious too - in retrospect, of course. > > The only thing I don't like about it is it still joins > everything, even if it only needs 3 out of 10,000 elements. > How about a simple change of the first line to: $str = join ', ', @names[0..30]; With a "," and a " ", each element must have at least 3 characters (ignoring the posibility of empty elements), so there will be at most 30 entries in the final string. I include the 31st to trigger the ", etc.". [Others have presented very similar ideas] Chris
Re: Iterating down two lists at the same time
Hmm... I just finished my solution when I saw the mapcar one posted by Evan. Well, here's mine anyway. It is worse because: 1) it's not a package, 2) it doesn't support aliased variables (i.e. you can't modify the incoming arrays like you can with map). But, it does use letters $a, $b, $c, etc. as Bernie requested. Mine operates on the minimum number of elements, instead of the maximum, in all of the arrays. Perl6 could do this better with variable aliases. #!/usr/bin/perl sub mapn(&@) { my $coderef = shift; return () if (@_==0); my $n = @{$_[0]}; my @result; foreach my $arg (1 .. $#_) { $n = @{$_[$arg]} if (@{$_[$arg]} < $n); } foreach $i (0..$n-1) { foreach my $arg (0 .. $#_) { my $letter = chr(ord('a') + $arg); $$letter = $_[$arg]->[$i]; } push @result, &$coderef; } @result; } my @one = qw(foo bar baz fwip); my @two = qw(spam ham jam flimflam); my @tri = qw(1 2 3 4); my @out = mapn {"$c:$a:$b"} \@one, \@two, \@tri; print "@out\n"; Chris Bernie Cosell wrote: > On 29 Oct 2002 at 13:05, Bernie Cosell wrote: > > >>I'm cobbling up a bit of code that'll need to do something akin to 'map' on two >>lists at the same time. ... > > > Footnote: I realized, that while doing 'mapN' is interesting. what I'm actually > in the midst of implementing is 'foreach' for multiple lists. The template I > had in mind was something like: >forall my ($lotsofvariables) (list of listrefs) > and then it'd alias the vbls in the lotsofvariables [or en masse if there's an > array, of course] to each parallel entry from the various lists. > > I wonder if there's a pretty/elegant way to do that... > > /bernie\ >
Re: diff between hyphenated and non-hyphenated version of a word
Bart Lateur wrote: > When thinking of a user-friendly interface to let a user define a table > of words and their hyphenated forms, I stumbled across this cute > problem. It's simple enough to be a fun puzzle, yet not too hard to be > labour. It might even be a fun task for Perl Golf. > > The problem is this: given two versions of a word, one without, and one > with hyphenation, determine which hyphens are soft hyphens (optional > breakpoints), and which ones are hard hyphens? For example: > > hypo-allergeen hy-po-al-ler-geen > > (If you wonder about the hyphenation rules: Dutch) > > Here, all hyphens are soft hyphens, except the one between the "o" and > the "a", which is required (I guess. I'm not 100% about the spelling, > people seem to disagree on that one), or at least, let's suppose so. > > So, a short and sweet snippet that figures this out, please? The result > may be whatever form you like. > This is cheating because it uses a non-core module, but here's a short one that removes the soft hyphens: perl -le'use Algorithm::Diff LCS;print LCS map[/./g],@ARGV' hy-po-al-ler-geen hypo-allergeen output: hypo-allergeen Chris
Re: perl5.6.1 oddity?
Sorry for the newbie-ish question, but can someone explain why = does not warn? Is it because (quoting perlop) $a += 2; is equivalent to $a = $a + 2; although without duplicating any side effects that dereferencing the lvalue might trigger and the warn is considered a side effect? Or is it just a kluge to support someone developer's personal preferences? Is it possible to enable warnings for this case in 5.8? In my coding style, I would consider it a bug to append to an undef scalar like in Michael's example quoted below. The implicit conversion of $foo to the null string before appending 42 is a no-no in my opinion. Chris Jeff 'japhy' Pinyan wrote: > On Jun 14, Bart Lateur said: > > >>On Fri, 14 Jun 2002 00:21:16 -0400, Michael G Schwern wrote: >> >> >>>The history is someone noticed that since this: >>> >>> my $foo; $foo = $foo . 42 >>> Use of uninitialized value at -e line 1. >>> >>>and this: >>> >>> my $foo; $foo .= 42 >>> >>>are logically the same, the former shouldn't warn. >> >>Perhaps... (I feel like disagreeing, though.) >> >>Anyway: >> >> my($foo, $bar); $foo = $bar . 42; >> >>*should* warn. Only in the exceptional case where the lvalue on the left >>is identical to the lvalue first thing on the right, the warning might >>be dropped. Well: it doesn't warn. That makes no sense at all, either >>'.' should warn (pretty much) always, or never. >> >>And that's where my disagreement kicks in. The rules used to be much >>simpler: '.' warns, '.=' doesn't. I feel that rule make much more sense, >>"logically the same" or not. If you don't want the warning, use '.='. > > > Yeah, if we start allowing undef values when they're being used for > concatenation, we'll stop being warned when we might want to be. :( >
Re: regex for html tags
[EMAIL PROTECTED] wrote: > [snip] > It's like saying ice-fishing is part of the American culture, just > because a bunch of people in Alaska do that in winter. Point taken, but just to nitpick your choice of analogies, it is clear that you have never lived in the upper Midwest of the US, or you would know that you cannot truly be an American if you have never ice-fished. :-) Please see Dave Barry's recent column as the definitive exposition on ice fishing as a crucial element of our culture. http://www.miami.com/mld/miamiherald/living/columnists/dave_barry/2779904.htm All the talk of the Antarctic ice shelf in the news today probably has many of my neighbors drooling with envy, now that all of the local lakes have thawed. Chris
Re: longest common substring (return of)
This is very much not my area, so I don't know if this is a good or bad recommendation, but here goes anyway... :-) Algorithm::Diff has an LCS function. It's not very fast, but it has worked well for my purposes in the past. Chris Ted Zlatanov wrote: > I remember a lengthy LCS discussion, and the solutions for the most > part used the regex engine. I also looked on CPAN, but couldn't find > a canonical LCS module. > > Has anyone developed an implementation of the well-known bitstring > algorithm? Basically you convert your data strings to bitstrings, AND > the two, and look for the longest match. Then you rotate the shorter > data string by one, and repeat the test. Repeat for the number of > bits in the shorter data string. I want to do it, but just wanted to > check if it had come up before on FWP. > > There are even better algorithms to do this. I found them with > Google; for instance the Goeman & Clausen 1999 "A New Practical Linear > Space Algorithm for the LCS Problem" paper looks interesting but is > beyond what I remember of my college math. It describes a > O(ns + min(mp, (m log(m)) + p(n-p))) time, linear space algorithm and a > O(ns + min(mp, p(n-p))) time, O(ns) space algorithm, and claims the > latter to be the fastest known such algorithm (m = size of string A, > n = size of string B, n>= m, s = alphabet size, p = length of LCS). > I'm pretty sure implementations of the Goeman & Clausen algorithms > haven't been done in Perl yet. >
Re: TPR1 post-mortem
Prakash Kailasa wrote: > > I request others to follow with their own accounts about how they > arrived at their formula(e|s). I am especially intrigued with the > usage of hex() by Ton and Chris (I haven't looked at all the results, > so there might be others too). How the heck did you guys think of such > a thing? > Like others did, I built a chart perl -le 'for$i(0..9){for$j(0..9){printf"%3d",$i+$j}print}' 0 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 10 2 3 4 5 6 7 8 9 10 11 3 4 5 6 7 8 9 10 11 12 4 5 6 7 8 9 10 11 12 13 5 6 7 8 9 10 11 12 13 14 6 7 8 9 10 11 12 13 14 15 7 8 9 10 11 12 13 14 15 16 8 9 10 11 12 13 14 15 16 17 9 10 11 12 13 14 15 16 17 18 and noted that I wanted everything above 9 to be smaller. First I played with %9 but I got the unfortunate result that while 10%9 is 1, as desired, 9%9 is zero, not 9. I decided I needed a gap between 9 and 10, and it occured to me that interpreted in a base larger than 10, there would be a gap. I also realized that the reason that %9 was attractive was that it was the largest single-digit number. So perl -le 'for$i(0..9){for$j(0..9){printf"%3d",hex($i+$j)%15}print}' 0 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 gives the right chart. The 15 is crucial because in hex, its the largest single digit number. My biggest failing in this competition is that I couldn't get the $` approach to work so I was stuck with $' and chop. Ton's ingenious ^s//pop/e was the thing I was missing. Chris
Re: TPR course Beginner vs. Veteran
Jean-Pierre Vidal wrote: > > On January 30, 2002, I asked on fwp for a similar question, which result was > the thread "beginner's definition". > Now my opinion is "enter golf as you want". You can see beginners over > veterans, and vice versa. For me, the meaning of beginner's board is "play > with us, please, even if you don't want to be considered a veteran". > Perhaps I never had entered a golf course if there was not a beginners' > leaderboard. > Ahh, thanks for the reference. I hadn't gotten that far back in the archives yet. After reading, I agree that people should join whichever board on which they feel comfortable. But I still say that to a first-timer, the "Beginner"/"Veteran" checkboxes are ambiguous. A one-sentence explanation would go a long ways to making a newcomer feel more confident. However, I should say that the more I read the fwp archives, the more intimidated I get! I didn't realize how much I had handicapped myself by not upgrading perl5.6.0->5.6.1!!! :-) Chris
Re: BoB
Isn't listing the number of [^\w\s] a little too big a hint? For example, it might have given away the technique for TPR(0,0) since the winners had so many \w characters. Maybe the leaderboard should just silently sort the ties. Chris Jerome Quelin wrote: > On Mardi 5 Mars 2002 08:06, [EMAIL PROTECTED] wrote : > >>Since Rick is ahead of Ton on the leaderboard are we to assume >>that he is ahead on the tie-break rule? Perhaps the leaderboard >>could be updated with the tie break score too? (i.e. the >>'matched 123 [^\w\s]' score from running the test program). > > > 52 strokes (matched 23) for Ton. > 52 strokes (matched 23) for Rick. > 52 strokes (matched 27) for BoB. > > The leaderboard is to display someone first, that was Rick. But there is a > tie, since they have the same number of [^\w\s] chars. > Next tournaments will display the tie-breaker score. > > Jerome
TPR course Beginner vs. Veteran
Fellow TPR Golfers, For future TPR golf courses, I think it should be more clear what constitutes a "Beginner" vs. a "Veteran". Currently, it's ambiguous in that it could mean: * veteran programmer * veteran Perl programmer * veteran Perl Golfer I, for example, am the first two but not the third. I chose "Veteran" because my ego said said I could compete on that board :-) but I can see someone easily making a mistake and being stuck with too easy/too hard competition. Right now there is no easy way for a golfer to change which board he/she is on. Perhaps, a beginner should be allowed to promote himself to veteran mid-game (but certainly not the other direction, or abuse will happen) and a note on the submit page could say something like "If you are unsure if you are a beginner or a veteran, choose beginner. You can change to veteran later if you like." Just some thoughts... /dev/null me if this has already been discussed. I'm new to fwp and have only read the mail archives a few weeks back. Chris
Re: TPR(0,1) scores
Dave Hoover wrote: > Yanick wrote: > >>I quickly hacked a little page that slurp the scores off >>the official page and make a histogram out of it. >> > > That's awesome! And I like the 'sandtrap' metaphor much better than the > disparaging 'rejects' that we're currently using. I think I'll steal that > one from you, OK? > > Question: how will it scale as the number of golfers grow? Will it push off > the right side of the page? It fits nicely in my browser right now, but I'm > not sure how well it would scale to the 73 veteran golfers we had last > month. :-) > I agree with Dave. It would scale better if you rotated the histogram 90 degrees so you could have the golfer name in column 1 and the score bar extending horizontally to the right in column 2. Then as the number of golfers got large, the page would scroll vertically instead of horizontally. Chris