Re: Golf this.

2002-07-16 Thread Andrew . Savige
En op 17 juli 2002 sprak Kristen Thelen's hubby: > I've come up with a couple other 20s: > > 20 print\@h{<>}&&sort%h > 20 print!\@h{<>},sort%h (not sure why this works, so maybe it doesn't:) Hurrah! I'm going backwards! 27 print sort%{{map{$_,""}<>}} But at least I got rid of that annoying %h

Re: Golf this.

2002-07-16 Thread Michael W Thelen
On Tue, Jul 16, 2002 at 08:50:14PM +, Ton Hospel wrote: > > Here's a 20 that looks like it still has room for improvement: > > > > 20 \@h{<>},print sort%h > > > Mm, interesting generally useful technique. I think you have just become > inventor of something that will soon be a standard golfi

Re: Golf this.

2002-07-16 Thread Ton Hospel
In article <[EMAIL PROTECTED]>, Michael W Thelen <[EMAIL PROTECTED]> writes: > On Tue, Jul 16, 2002 at 09:45:21AM -0700, Rick Klement wrote: >> But this seems to :) >> >> 21 print@h{<>}="",sort%h > > Here's a 20 that looks like it still has room for improvement: > > 20 \@h{<>},print so

Re: Golf this.

2002-07-16 Thread Michael W Thelen
On Tue, Jul 16, 2002 at 09:45:21AM -0700, Rick Klement wrote: > But this seems to :) > > 21 print@h{<>}="",sort%h Here's a 20 that looks like it still has room for improvement: 20 \@h{<>},print sort%h -- Mike -- Michael W. Thelen eval unpack u,'M*"1C/22\A+48O82UZ+SME=F%L*"1C+B(G=2HGM+"

Re: Golf this.

2002-07-16 Thread Rick Klement
Michael W Thelen wrote: > > On Tue, Jul 16, 2002 at 09:16:40AM -0600, Michael W Thelen wrote: > > I'm not entirely sure why this works, but here's a 21: > > > > 21 print sort@h{<>}=0,%h > > Never mind, the reason I didn't understand why it worked is because it doesn't. > :-) Sorry bout that. B

Re: Golf this.

2002-07-16 Thread Michael W Thelen
On Tue, Jul 16, 2002 at 09:16:40AM -0600, Michael W Thelen wrote: > I'm not entirely sure why this works, but here's a 21: > > 21 print sort@h{<>}=0,%h Never mind, the reason I didn't understand why it worked is because it doesn't. :-) Sorry bout that. -- Mike -- Michael W. Thelen eval unpa

Re: Golf this.

2002-07-16 Thread Michael W Thelen
On Tue, Jul 16, 2002 at 07:44:41AM -0700, Rick Klement wrote: > Yep, I make it 25 strokes also. > > 25 -p $h{$_}=""}for(sort%h){ > > Mind if I play through? > > 22 @h{<>}="";print sort%h I'm not entirely sure why this works, but here's a 21: 21 print sort@h{<>}=0,%h -- Mike -- Michael W. T

Re: Golf this.

2002-07-16 Thread Rick Klement
[EMAIL PROTECTED] wrote: > > But, is this the shortest algorithm? Using a hash? > > 29 strokes? > > I make it 25 strokes: > -p $h{$_}=""}for(sort%h){ > > I cannot answer if it is the shortest. > Only The Alien can answer that. > > /-\ Yep, I make it 25 strokes also. 25 -p $h{$_}=""}for(sort%h

Re: Golf this.

2002-07-16 Thread Francesc X . Noria
On Tue, 16 Jul 2002 11:36:45 +0200 Paul Johnson <[EMAIL PROTECTED]> wrote: : perl -MO=Deparse -pe '$h{$_}=""}for(sort%h){' Ah, excellent! Now I undertand the discussion on the value to be assigned as well. Thank you! -- fxn

Re: Golf this.

2002-07-16 Thread Paul Johnson
On Tue, Jul 16, 2002 at 11:22:46AM +0200, Francesc X.Noria wrote: > On Tue, 16 Jul 2002 16:07:33 +1000 > [EMAIL PROTECTED] wrote: > > : How about this? > : > : #!perl -p > : $h{$_}=""}for(sort%h){ > > I cannot see how that works. Why is $_ not printed in each loop? How > that strange position o

Re: Golf this.

2002-07-16 Thread Francesc X . Noria
On Tue, 16 Jul 2002 16:07:33 +1000 [EMAIL PROTECTED] wrote: : How about this? : : #!perl -p : $h{$_}=""}for(sort%h){ I cannot see how that works. Why is $_ not printed in each loop? How that strange position of braces (...}...{) work? When and how is the for looping? I would be very grateful if

Re: Golf this.

2002-07-16 Thread Rick Myers
On Jul 16, 2002 at 17:14:00 +1000, [EMAIL PROTECTED] wrote: > set it to "" and not a number. Rick's > -p $h{$_}=1}for(sort%h){ > suffers from the same bug. Ever wonder why something seems just tooo easy? I digress. I didn't read the requirement nearly long enough. In fact, I don't recall readi

Re: Golf this.

2002-07-16 Thread BenoƮt Chauvet
- Original Message - > En op 16 juli 2002 sprak |3en: > > Hu... I may make a mistake, but... > > > > Isn't this one... > > -p $h{$_}++}for(sort%h){ > > > > ...shorter ? > > Yes |3en, this is your third mistake. > Your first was challenging `/ in tpr04, and your > second was challenging h

Re: Golf this.

2002-07-15 Thread Andrew . Savige
En op 16 juli 2002 sprak |3en: > Hu... I may make a mistake, but... > > Isn't this one... > -p $h{$_}++}for(sort%h){ > > ...shorter ? Yes |3en, this is your third mistake. Your first was challenging `/ in tpr04, and your second was challenging him yet again in tpr04b. Because we are using %h and

Re: Golf this.

2002-07-15 Thread Rick Myers
On Jul 16, 2002 at 16:32:34 +1000, [EMAIL PROTECTED] wrote: > > I make it 25 strokes: > -p $h{$_}=""}for(sort%h){ -p $h{$_}=1}for(sort%h){ ;-) --rick

Re: Golf this.

2002-07-15 Thread Andrew . Savige
En op 16 juli 2002 sprak Tor Hildrum: >> open F,$_[0];while(){$h{$_}=$i;}foreach$k(%h){print"$k";} > ^ >Should be $ARGV[0] > > Yours removes duplicates but does not sort. > How about this? > > #!perl -p > $h{$_}=""}for(sort%h){ > > Ah. :) > {$h{$_}=""}for(sort%h){print} > >Gives

Re: Golf this.

2002-07-15 Thread Tor Hildrum
<[EMAIL PROTECTED]> wrote: >> open F,$_[0];while(){$h{$_}=$i;}foreach$k(%h){print"$k";} ^ Should be $ARGV[0] > Yours removes duplicates but does not sort. > How about this? > > #!perl -p > $h{$_}=""}for(sort%h){ Ah. :) {$h{$_}=""}for(sort%h){print} Gives an additional newli

Re: Golf this.

2002-07-15 Thread Andrew . Savige
En op 16 juli 2002 sprak Tor Hildrum: >I was considering starting a first ever newbie golf hole, > but I chickened out. > > I would still like some help with golfing my solution down a couple of > strokes. It's pretty trivial: > > open F,$_[0];while(){$h{$_}=$i;}foreach$k(%h){print"$k";}' > > It's