New golf "spiral"

2003-01-21 Thread Terje Kristensen
Hi all,

First, thanks to all who played the "LED" display golf and congratulations 
to the winners ton and mtve and tybalt for their great solutions.

The new golf course "spiral" is now open. The problem is straight forward, 
but the solutions migh be long :)

Hope to see you there.

Terje K





Perl vs. C?

2003-01-21 Thread Ian Phillipps
The following was distributed a while ago as "footguy.c".
Can any golfers duplicate its function in perl using fewer characters?

There are a couple of literal ^G in here:

main(l){main(8^putchar(l++["xx77Rd$fR$wPP"]^88)?l:26+fflush(sleep(1))-l);}

In case you can't get this to work, it displays this:
 oo
<|>
_|_

alternating with this:

 oo
<|>
_|/

once per second.
To match the C program, you need to send the output to STDOUT, not
STDERR - but a stderr-producing perl version would be of interest.

Try http://www.waste.org/footguy/ - but you need at least Netscape 1.1
for this site to work.

Ian



Re: Perl vs. C?

2003-01-21 Thread Yanick
On Wed, Jan 22, 2003 at 12:08:23AM +, Ian Phillipps wrote:
> The following was distributed a while ago as "footguy.c".
> Can any golfers duplicate its function in perl using fewer characters?
> 
> There are a couple of literal ^G in here:
> 
> main(l){main(8^putchar(l++["xx77Rd$fR$wPP"]^88)?l:26+fflush(sleep(1))-l);}

One first, naive try:

perl -i_ -e'$_||=" oo\n<|>\n_|_\n",s#.$#$&eq$^I?"/":$^I#e while sleep print'

Change the \n for real carriage returns and $^I for hard ^I's and you
can save a few strokes more...

Joy,
`/anick
 
-- 
"Basically, I no longer work for anything but the sensation I have while working."
- Albert Giacometti (sculptor)



Re: Perl vs. C?

2003-01-21 Thread Yanick
On Tue, Jan 21, 2003 at 09:39:18PM -0500, Yanick wrote:
> On Wed, Jan 22, 2003 at 12:08:23AM +, Ian Phillipps wrote:
> > The following was distributed a while ago as "footguy.c".
> > Can any golfers duplicate its function in perl using fewer characters?
> > 
> > There are a couple of literal ^G in here:
> > 
> > main(l){main(8^putchar(l++["xx77Rd$fR$wPP"]^88)?l:26+fflush(sleep(1))-l);}
> 
>   One first, naive try:
> 
>   perl -i_ -e'$_||=" oo\n<|>\n_|_\n",s#.$#$&eq$^I?"/":$^I#e while sleep print'

A second, almost as naive, try:

perl -e'$_="oo\n<|>\n_|";sleep print while$\=("_\n","/\n")[--$|]'

Joy,
`/anick

-- 
When I was a young man I vowed never to marry until I found the ideal
woman. Well, I found her but, alas, she was waiting for the ideal man.



Re: Perl vs. C?

2003-01-21 Thread Yanick
On Tue, Jan 21, 2003 at 09:48:51PM -0500, Yanick wrote:
> On Tue, Jan 21, 2003 at 09:39:18PM -0500, Yanick wrote:
> > On Wed, Jan 22, 2003 at 12:08:23AM +, Ian Phillipps wrote:
> > > The following was distributed a while ago as "footguy.c".
> > > Can any golfers duplicate its function in perl using fewer characters?
> > > 
> > > There are a couple of literal ^G in here:
> > > 
> > > main(l){main(8^putchar(l++["xx77Rd$fR$wPP"]^88)?l:26+fflush(sleep(1))-l);}
> > 
> > One first, naive try:
> > 
> > perl -i_ -e'$_||=" oo\n<|>\n_|_\n",s#.$#$&eq$^I?"/":$^I#e while sleep print'
> 
>   A second, almost as naive, try:
> 
>   perl -e'$_="oo\n<|>\n_|";sleep print while$\=("_\n","/\n")[--$|]'

perl -e'sleep print"oo\n<|>\n_|"while$\=("_\n","/\n")[--$|]'

(sorry, I'll shut up, now)

`/.

-- 
"For those who want prayer in school, I'm willing to 
consider a tradeoff: algebra in church. If you're so hot on 
absolute truth, I've got absolute truth for you."
- comic book writer Steven Grant



Re: Perl vs. C?

2003-01-21 Thread Rick Klement
Ian Phillipps wrote:
> 
> The following was distributed a while ago as "footguy.c".
> Can any golfers duplicate its function in perl using fewer characters?
> 
> main(l){main(8^putchar(l++["xx77Rd$fR$wPP"]^88)?l:26+fflush(sleep(1))-l);}
> 

How about:

  perl -e's//_\b/;$_^=p while sleep print" oo\n<|>\n_|"x!$|++,$_'

and it fixes a bug in the C version where the last line of the footguy
isn't drawn until after the first sleep.

To be fair, the perl -e'' shouldn't count, so:

76: main(l){main(8^putchar(l++["xx77Rd$fR$wPP"]^88)?l:26+fflush(sleep(1)1);}

54: s//_\b/;$_^=p while sleep print" oo\n<|>\n_|"x!$|++,$_

Darn, only 22 strokes shorter  :(

-- 
Rick Klement