Re: TPR0 Final Results

2002-03-07 Thread Rick Klement

[EMAIL PROTECTED] wrote:
 
 Ton Hospel schreef op 21 februari 2002:
  $\=(30+ord lc)%39+36*$\.$/for pop=~/./g;print
 
  Hey, that's 45! Stephen, are you happy now?
  Ton, you are the best golf post-mortem analyst in the world. :)
 
  You did all the hard work, I just moved some chars around.
 
 Eugene van der Pijll schreef op 3 februari 2002:
  Beaten? I not understand! The Andrew-Ton collective: 90 Eugene: 89.
  Besides, your solution fails for long files.
 
 I hope this 45 restores some credibility to the Andrew-Ton collective
 whose motto is: If you can't win the game, win the post-mortem. :)
 
 /-\ndrew

And if you can't win the game or the previous game, try to win the
previous game's post-mortem...

Crossing the 45

$\=(30+ord lc)%39+36*$\.$/for pop=~/./g;print

with the 58 by Michael Assels (which was falsely accepted, it fails for 7,8,9)

-l $_=pop;$x+=36**$y++*((ord chop)%55%48)while$_;print$x+0

and tweaking slightly, one gets:

$\=ord(lc)%87%48+36*$\.$/for pop=~/./g;print

which is a 44  :)

-- 
Rick Klement



Re: TPR0 Final Results

2002-02-22 Thread Ton Hospel

In article [EMAIL PROTECTED],
[EMAIL PROTECTED] writes:
 Andrew Savige schreef op 22 februari 2002:
 #!/usr/bin/perl -l
 [pop=~/.(?{$a=$a*36+(ord(lc$)-9)%39})/g];print$a

 why do you need the [] ?
 
 OK, I understand it now. The [] provides the list context
 to force iteration of the whole string. For example:
   $x = 'abc';
   @a=$x=~/.(?{print$})/g;
   $x=~/.(?{print$})/g;
 The @a case above prints 'abc' while the next line prints just 'a'.
 
Yup. and the other way to get (?{}) constructs to be loop is to cause
backtracing, e.g. something like:
perl -wle 'abcd =~ /(??{print $`})/'



Re: TPR0 Final Results

2002-02-21 Thread Andrew . Savige

Andrew Savige schreef op 22 februari 2002:
 #!/usr/bin/perl -l
 [pop=~/.(?{$a=$a*36+(ord(lc$)-9)%39})/g];print$a

 why do you need the [] ?

OK, I understand it now. The [] provides the list context
to force iteration of the whole string. For example:
  $x = 'abc';
  @a=$x=~/.(?{print$})/g;
  $x=~/.(?{print$})/g;
The @a case above prints 'abc' while the next line prints just 'a'.

/-\ndrew



Re: TPR0 Final Results

2002-02-20 Thread Stephen Turner

On Wed, 20 Feb 2002 [EMAIL PROTECTED] wrote:

 Ton Hospel schreef op 20 februari 2002:
  $\=(30+ord lc)%39+36*$\.$/for pop=~/./g;print
 
 Hey, that's 45! Stephen, are you happy now?
 Ton, you are the best golf post-mortem analyst in the world. :)
 

Very happy, thank you. Not only did you find a better solution, but I learnt
a new trick with this $\

-- 
Stephen Turner, Cambridge, UKhttp://homepage.ntlworld.com/adelie/stephen/
This is Henman's 8th Wimbledon, and he's only lost 7 matches. BBC, 2/Jul/01




Re: TPR0 Final Results

2002-02-20 Thread Andrew . Savige

Ton Hospel schreef op 21 februari 2002:
 $\=(30+ord lc)%39+36*$\.$/for pop=~/./g;print
 
 Hey, that's 45! Stephen, are you happy now?
 Ton, you are the best golf post-mortem analyst in the world. :)
 
 You did all the hard work, I just moved some chars around.

Eugene van der Pijll schreef op 3 februari 2002:
 Beaten? I not understand! The Andrew-Ton collective: 90 Eugene: 89.
 Besides, your solution fails for long files.

I hope this 45 restores some credibility to the Andrew-Ton collective
whose motto is: If you can't win the game, win the post-mortem. :)

/-\ndrew



Re: TPR0 Final Results

2002-02-20 Thread Yanick

On Thu, Feb 21, 2002 at 12:21:14PM +1100, [EMAIL PROTECTED] wrote:
 I hope this 45 restores some credibility to the Andrew-Ton collective
 whose motto is: If you can't win the game, win the post-mortem. :)

Might I propose an alternative motto: 

Beating dead (golf) courses' our specialty ? 

;)

`/anick

-- 
I swear, by my life and my love of it, that I will never live 
for the sake of anotherman, nor ask another man to live for 
mine. - John Galt's pledge from Ayn Rand's Atlas Shrugged 



Re: TPR0 Final Results

2002-02-19 Thread Prakash Kailasa

On Tue, Feb 19, 2002 at 01:27:52AM +0100, Philippe 'BooK' Bruhat wrote:
 On Sat, 16 Feb 2002, Paul Johnson wrote:
 
  On Fri, Feb 15, 2002 at 11:47:27PM +, Stephen Turner wrote:
  
   Well, I repeat my challenge. Can anyone beat Karsten's 46 without using
   POSIX?
  
  I think my entries must have been late, but here's a 41.
  
  #!/usr/bin/perl -l
  $_=pop;print/A/?360:/B/?47:/Z/?46655:1
  __END__
  
 One char shorter... but still cheating ;-)
 
 #!/usr/bin/perl -l
 print{1,1,A,360,B,47,Z,46655}-{+pop}

This would fail the test program. You need to change it to:

#!/usr/bin/perl -l
print{1,1,A0,360,'1B',47,ZZZ,46655}-{+pop}

which would make it 46 chars.

Stephen's cheating works because he is using regexes and the base36
values in the test program favored his approach so he could manage
with single character regexes.

/prakash
-- 
Prakash Kailasa mailto:[EMAIL PROTECTED]
==
  echo Congratulations.  You aren't running Eunice.
   -- Larry Wall in Configure from the perl distribution
==



Re: TPR0 Final Results

2002-02-19 Thread Philippe 'BooK' Bruhat

En réponse à Prakash Kailasa [EMAIL PROTECTED]:

 On Tue, Feb 19, 2002 at 01:27:52AM +0100, Philippe 'BooK' Bruhat wrote:
  
  #!/usr/bin/perl -l
  print{1,1,A,360,B,47,Z,46655}-{+pop}
 
 This would fail the test program. You need to change it to:
 
 #!/usr/bin/perl -l
 print{1,1,A0,360,'1B',47,ZZZ,46655}-{+pop}
 
 which would make it 46 chars.

Actually, that's what I sent to the judges (which they refused).
I rewrote it quicly when answering Stephen's email, but forgot to try it
against the test program, trusting what my eyes read in his entry.

Anyway, 46 is still better than my best legal shot. ;-)
 
 Stephen's cheating works because he is using regexes and the base36
 values in the test program favored his approach so he could manage
 with single character regexes.

Yep. Note to self: think before you post!

-- 
 Philippe BRUHAT - BooK

 When you run from your problem, you make it that much harder for good
 fortune to catch you, as well. (Moral from Groo The Wanderer #14 (Epic))



Re: TPR0 Final Results

2002-02-19 Thread Stephen Turner

On Tue, 19 Feb 2002, Prakash Kailasa wrote:
 
 Stephen's cheating works because he is using regexes and the base36
 values in the test program favored his approach so he could manage
 with single character regexes.
 

It was not my cheating.

I'm still interested in seeing a real solution less than 46. But maybe there
isn't one.

-- 
Stephen Turner, Cambridge, UKhttp://homepage.ntlworld.com/adelie/stephen/
This is Henman's 8th Wimbledon, and he's only lost 7 matches. BBC, 2/Jul/01





Re: TPR0 Final Results

2002-02-19 Thread Prakash Kailasa

On Tue, Feb 19, 2002 at 02:51:45PM +, Stephen Turner wrote:
 On Tue, 19 Feb 2002, Prakash Kailasa wrote:
  
  Stephen's cheating works because he is using regexes and the base36
  values in the test program favored his approach so he could manage
  with single character regexes.
  
 
 It was not my cheating.

My apologies. It was Paul Johnson's. I misread the attributions in
Philippe's earlier message.

 I'm still interested in seeing a real solution less than 46. But maybe there
 isn't one.

I am waiting too.

/prakash
-- 
Prakash Kailasa mailto:[EMAIL PROTECTED]
==
  Though I'll admit readability suffers slightly...
   -- Larry Wall in [EMAIL PROTECTED]
==



Re: TPR0 Final Results

2002-02-19 Thread Andrew . Savige

Stephen Turner schreef op 20 februari 2002:
 I'm still interested in seeing a real solution less than 46.
 But maybe there isn't one.

Since we have had a positive sighting of Eugene whittling at the
RC4 solution, I doubt that it is possible. ;-)

I had visions of reliving Eugene's celebrated reverse in Santa's
game by using the $\ variable, but I can't get it below 48.
It would be a winner were it not for the newline requirement.

Since variety is the spice of life, I present 5 permutations
of Spiff's solution using various special variables. If there
happened to be a Perl built-in array with value (,\n), the
last one would be 45.

spiff 46:
map$.=36*$.-55+/\d/*7+ord,pop=~/./g;print$..$/

46:
map$,=36*$,-55+/\d/*7+ord,pop=~/./g;print,$/

41 (but, alas, not new-line terminated):
map$\=36*$\-55+/\d/*7+ord,pop=~/./g;print

48:
map$\=36*$\-55+/\d/*7+ord,pop=~/./g;$\.=$/;print

56:
@a=(,$/);map$=36*$-55+/\d/*7+ord,pop=~/./g;print@a

/-\ndrew



Re: TPR0 Final Results

2002-02-19 Thread Andrew . Savige

Three more 46-ers:

map$.=36*$.-55+/\d/*7+ord,pop=~/./g;print$..$/spiff:46
map$\=(36*$\-55+/\d/*7+ord).$/,pop=~/./g;printGhost of
  Eugene's reverse
map$\=36*$\-55+/\d/*7+ord().$/,pop=~/./g;printGhost of
  Eugene's reverse
$\=(36*$\-55+/\d/*7+ord).$/for pop=~/./g;printGhost of
  Eugene's reverse

That ord() is *so* annoying.

/-\ndrew



Re: TPR0 Final Results

2002-02-19 Thread Andrew . Savige

Two more:

$a=$a*36+(30+ord lc)%39for pop=~/./g;print$a,$/ ton:47
$\=$\*36+(30+ord lc)%39 .$/for pop=~/./g;print  ton's ghost:46

$x=$x*36+(-9+ord)%39for split//,lc pop;print$x.$/   albert:49
$\=$\*36+(-9+ord lc)%39 .$/for pop=~/./g;print  albert's ghost:46

Now the space after the 39 is driving me crazy.

/-\ndrew



Re: TPR0 Final Results

2002-02-19 Thread Andrew . Savige

Ton Hospel schreef op 20 februari 2002:
 $\=(30+ord lc)%39+36*$\.$/for pop=~/./g;print

Hey, that's 45! Stephen, are you happy now?
Ton, you are the best golf post-mortem analyst in the world. :)

/-\ndrew



Re: TPR0 Final Results

2002-02-18 Thread Philippe 'BooK' Bruhat

On Sat, 16 Feb 2002, Paul Johnson wrote:

 On Fri, Feb 15, 2002 at 11:47:27PM +, Stephen Turner wrote:
 
  Well, I repeat my challenge. Can anyone beat Karsten's 46 without using
  POSIX?
 
 I think my entries must have been late, but here's a 41.
 
 #!/usr/bin/perl -l
 $_=pop;print/A/?360:/B/?47:/Z/?46655:1
 __END__
 
One char shorter... but still cheating ;-)

#!/usr/bin/perl -l
print{1,1,A,360,B,47,Z,46655}-{+pop}

-- 
 Philippe BooK Bruhat

 No one profits at the death of another (except for the mortician).
 (Moral from Groo The Wanderer #7 (Epic))




Re: TPR0 Final Results

2002-02-16 Thread Andrew . Savige

Andrew Savige wrote:
 #!/usr/bin/perl -l
 use POSIX;print strtol pop,36
 
 I think this should work, but it prints a spurious trailing zero.

Ronald J Kimball wrote:
 RTFM.

strtol  String to (long) integer translation.  Returns the
parsed number and the number of characters in the
unparsed portion of the string

In retrospect, I am astonished that I did not go to the trouble
of 'perldoc POSIX' at any time. I knew I was being lazy, but that
is taking laziness to new heights! Maybe I was pre-occupied with
trying to win a T-shirt for the weirdest/wackiest entry.

I vaguely knew about strtol from ANSI C and just tried it and it
seemed to work as I expected. I spent all of 10 minutes on my
33-stroke solution (my previous best being 7918). At that point,
I remember feeling dirty to the point of being physically sick.
I thought about the true golf artists, like Spiff and Rick, toiling
to produce beautiful and elegant 46/47 stroke solutions and I go
ahead of them with this rubbish in 10 minutes. Like Bart, I felt
utterly bored and didn't spend any more time on strtol after that
(except to write a weird strtol-based 'Perl-is-C;C-is-Perl' entry).

`/anick-Zen-like looking inside myself, I know I lost to all those
golfers producing those brilliant 46/47-stroke solutions. I think
TPR should send Spiff a T-shirt and a cap; he really earned it.

/-\ndrew



Re: TPR0 Final Results

2002-02-16 Thread F . Xavier Noria

On Sat, 16 Feb 2002 11:10:41 +1100
[EMAIL PROTECTED] wrote:

: Stephen Turner wrote:
:  Can someone explain to me why
: 
:  -l use POSIX;print strtol pop,36
: 
:  doesn't work? Where does the extra 0 come from?

: Maybe Perl golf is useful, after all -- as a QA tool to find
: Perl bugs. :)

perldoc POSIX
/strtol

-- fxn




Re: TPR0 Final Results

2002-02-16 Thread F . Xavier Noria

On Sat, 16 Feb 2002 00:40:35 +0100
Bart Lateur [EMAIL PROTECTED] wrote:

: On Fri, 15 Feb 2002 08:53:45 -0600, Dave Hoover wrote:
: 
: Here is the winning solution:
: 
: #!perl -l
: use POSIX;print~~strtol pop,36
: 
: Boo, boo! 
: 
: What an anti-climax. Utterly boring.

Maybe being a mathematician I am a bit formalist, but the challenge was
to use as few strokes as possible, if you didn't use strtol you lost. If
you didn't want to use strtol as an option you are in your right. When I
play a game I try to win, that's all.

Moreover, once founded strtol, one had to squeeze the solution as much
as he knew, and that required, for instance, forcing scalar context with
the fewest strokes, learning about no working flags in the shebang,
finding alternatives for printing all over the docs, reading perldoc
perlvar ten times, reading POSIX.pm trying to discover something in the
sources that could bring some advantage, and what not, the 33 frontier
has been there various days to make our brains smoky. IMHO it was not
not that trivial, and not boring to me.

That work is the _same_ work we'll do in any future tournaments, whether
they involve modules or not, and is that work and learning from the
solutions of others what IMO makes golfing interesting and diverting.

-- fxn





Re: TPR0 Final Results

2002-02-16 Thread Bart Lateur

On Sat, 16 Feb 2002 11:10:17 +0100, F. Xavier Noria wrote:

: What an anti-climax. Utterly boring.

Maybe being a mathematician I am a bit formalist, but the challenge was
to use as few strokes as possible, if you didn't use strtol you lost. If
you didn't want to use strtol as an option you are in your right. When I
play a game I try to win, that's all.

So here's my solution:

use Foo;foo pop

The module Foo.pm still needs to be written, but that isn't relevant.

Oh, we can make both the module and the function names much shorter,
like just one character.

I'm sorry, but I think of using anything that isn't in the core language
as cheating.

-- 
Bart.



RE: TPR0 Final Results

2002-02-16 Thread Andrew . Savige

On Sat, 16 Feb 2002 11:10:17 +0100, F. Xavier Noria wrote:

: What an anti-climax. Utterly boring.

Maybe being a mathematician I am a bit formalist, but the challenge was
to use as few strokes as possible, if you didn't use strtol you lost. If
you didn't want to use strtol as an option you are in your right. When I
play a game I try to win, that's all.

Bart Lateur wrote:
 So here's my solution:

   use Foo;foo pop

 The module Foo.pm still needs to be written, but that isn't relevant.

 Oh, we can make both the module and the function names much shorter,
 like just one character.

 I'm sorry, but I think of using anything that isn't in the core
 language as cheating.

I think cheating is too strong a word, because the 33-strokers
were playing within the rules. And is there a fundamental difference
between strtol and unpack, say? They are both functions, after all.
If you set a golf problem that was directly solved by a single
call to unpack, that would be bad.

I don't feel strongly, but I would like the module rule to stand.
Just don't choose a problem that is directly solved by a module
function!! One of my reasons for the weird nature of the Get Even
game, is that I wanted to be certain to avoid a well known problem,
where people could search the Web and copy the solutions of others.

I have been involved in all 4 tournaments in the current series
(Santa, Ton, Get Even, TPR). So has Ton Hospel, and I would be
interested in hearing his opinion, as he produced both a
33-stroker and a 47-stroker in this game.

In my case, I produced my 33-stroker in about 10 minutes, without
even reading perldoc (as evidenced by my gaff). Yet, despite hours
of effort, 50 strokes was the best I could produce without using
a module. So I think the difference in order of difficulty is at
least 10 times. And I found the no module solutions *much* more
interesting and much better golfing.

/-\ndrew



Re: TPR0 Final Results

2002-02-16 Thread F . Xavier Noria

On Sat, 16 Feb 2002 11:28:51 +0100
Bart Lateur [EMAIL PROTECTED] wrote:

: On Sat, 16 Feb 2002 11:10:17 +0100, F. Xavier Noria wrote:
: 
: : What an anti-climax. Utterly boring.
: 
: Maybe being a mathematician I am a bit formalist, but the challenge was
: to use as few strokes as possible, if you didn't use strtol you lost. If
: you didn't want to use strtol as an option you are in your right. When I
: play a game I try to win, that's all.
: 
: So here's my solution:
: 
:   use Foo;foo pop
: 
: The module Foo.pm still needs to be written, but that isn't relevant.

Well, the game has rules and they say you can use core modules, so POSIX
is OK, whereas Foo.pm is not listed in the Camel book. In general using
a module will take too much strokes or won't help, and hence we won't
use them, but I think there is no need to forbid them, so people that
actually read documentation have a licit advantage. I have to say that
the name of my solutions were named this way

fxn-33-strokes-of-not-true-golfing:

however.

According to the rules I submitted this solution on Thursday:

use POSIX; print scalar strtol shift, 36:
#!/usr/bin/perl -l
$0=~s,.*u,u,;eval$0
__END__

(22 strokes) saying that in my opinion this trick should be explicitly
prevented, because might be considered legal otherwise and shouldn't be.
One rule was added and that solution was rejected (as I believed it had
to be, that's why I sent it). Probably the rule set will need a few
iterations until it becomes stable.

-- fxn




Re: TPR0 Final Results

2002-02-16 Thread F . Xavier Noria

On Sat, 16 Feb 2002 00:40:35 +0100
Bart Lateur [EMAIL PROTECTED] wrote:

: On Fri, 15 Feb 2002 08:53:45 -0600, Dave Hoover wrote:
: 
: Here is the winning solution:
: 
: #!perl -l
: use POSIX;print~~strtol pop,36
: 
: Boo, boo! 
: 
: What an anti-climax. Utterly boring.

Maybe being a mathematician I am a bit formalist, but the challenge was
to use as few strokes as possible, if you didn't use strtol you lost. If
you didn't want to use strtol as an option you are in your right. When I
play a game I try to win, that's all.

Moreover, once founded strtol, one had to squeeze the solution as much
as he knew, and that required, for instance, forcing scalar context with
the fewest strokes, learning about no working flags in the shebang,
finding alternatives for printing all over the docs, reading perldoc
perlvar ten times, reading POSIX.pm trying to discover something in the
sources that could bring some advantage, and what not, the 33 frontier
has been there various days to make our brains smoky. IMHO it was not
not that trivial, and not boring to me.

That work is the _same_ work we'll do in any future tournaments, whether
they involve modules or not, and is that work and learning from the
solutions of others what IMO makes golfing interesting and diverting.

-- fxn





Re: TPR0 Final Results

2002-02-16 Thread Ton Hospel

In article [EMAIL PROTECTED],
[EMAIL PROTECTED] writes:
 
 I have been involved in all 4 tournaments in the current series
 (Santa, Ton, Get Even, TPR). So has Ton Hospel, and I would be
 interested in hearing his opinion, as he produced both a
 33-stroker and a 47-stroker in this game.
 
In fact i also would like the module rule to remain. The whole idea of
perl5 was that the module functions get on roughly equal footing with the
normal functions. To me, they *are* part of the core, and indeed strtol is
not very different from unpack except that you need an extra use POSIX
(long in golf) to be able to use it.

Ok, in this case lots of people converged on a simular 33 solution, but 
I think it was just bad luck. Even if there are modules involved, with the
few strokes left there's often still enough extra room to do something
original (remember Eugene's reverse in the Santa golf).

In my case I started with a normal solution, I didn't even think of strtol.
My grep in the complete perl sources on 36 then hit strtol. In the
post-mortem you can see that I at first didn't realise that it was exported
by default, so that had me using things like ' to qualify the package and
weird exporter tricks. After a bit of time I by accident found strtol is
exported, and i had a 33 solution. 

But it's not over then. now you basically have to solve the problem:
give strtol scalar context and tag on a \n. I pretty soon found both the
basic 33-solutions by permuting ways to do that a bit. Again it's a bit of
a coincidence that these two methods produce the same result.

In fact, there's an almost 32 solution:

-l use POSIX;print-strtol-pop,36

which fails on a stderr message and does not work on arguments that start
with a number and contain a letter. But it has to be tried at least. How
many of the 33 people did ?

Another approach is to find a module that itself includes POSIX, and then
write something like, say,

-l no IO;print~~IO'strtol pop,36

Unfortunately all modules that load POSIX have very long names, and this 
would need a two-letter name or less.

Another thing I tried is to load it from the commandline. -M doesn't work,
but -d: does. unfortunately it looks in the wrong place, and you can't
easily get it to back up one directory.

So to me even the module solution involved:

- thinking of it at all or finding it (remember, most people didn't)
- realising it's exported
- trying ways to get scalar context and the \n tagged on (the two basic
  ways unfortunately happen to be equal length)
- finding alternative ways of loading the module

In general I would expect even module solutions to show more spread than
this one has. The framers of the competetion where just unlucky in that they
hit a task that's almost exactly solved by a module function, and that the
variations that are possible even in such a case here just didn't distinguish
among players enough. Normally the length of use module will exclude them
anyways unless they are extremely applyable.

Executive summary: I'm in favor of allowing modules



Re: TPR0 Final Results

2002-02-16 Thread Stephen Turner

On Fri, 15 Feb 2002, F.Xavier Noria wrote:
 
 Aha, is documented in perldiag:
 
Too late for -%s option
(X) The #! line (or local equivalent) in a Perl script
contains the -M or -m option.  This is an error
because -M and -m options are not intended for use
inside scripts.  Use the use pragma instead.
 
 So it seems that the shell invokes perl with the flag and perl itself
 does not handle it. Where is the difference from the perl's view of the
 execution? Why -M and -m options are not intended for use inside
 scripts?
 

It's a good question. Does anyone know why they should be forbidden? Is
there a technical reason preventing them working?

I mean, there are other command line arguments that have equivalents within
the program. For example, it doesn't say -w is not intended for use inside
scripts. Use $^W = 1 instead. I feel there must be more to it than that.

-- 
Stephen Turner, Cambridge, UKhttp://homepage.ntlworld.com/adelie/stephen/
This is Henman's 8th Wimbledon, and he's only lost 7 matches. BBC, 2/Jul/01




RE: TPR0 Final Results

2002-02-16 Thread Andrew . Savige

Stephen Turner wrote:
 In that case, I think there should be a separate leaderboard for
 people who didn't use strtol. Just so that I could be only one
 stroke off the lead, you understand. :-)

2002/02/11 19:52:29 - 46 - Karsten aka Spifff
map$.=36*$.-55+/\d/*7+ord,pop=~/./g;print$..$/

2002/02/11 17:54:43 - 47 - Stephen Turner
map{$a=$a*36+7*/\d/-55+ord}pop=~/./g;print$a


Oh deary me, Stephen, you beat Spiff by two hours but forgot
that map{$expr}list could be shortened to map$expr,list.
And, in the last game, you forgot that for could go at the end.

If you could just eliminate these silly blunders from your game,
you would be unbeatable! You remind me of a chess player who
makes one brilliant move after another, then throws it all
away by leaving his queen en-prise. :)

/-\ndrew



RE: TPR0 Final Results

2002-02-16 Thread Stephen Turner

On Sun, 17 Feb 2002 [EMAIL PROTECTED] wrote:
 
 Oh deary me, Stephen, you beat Spiff by two hours but forgot
 that map{$expr}list could be shortened to map$expr,list.
 And, in the last game, you forgot that for could go at the end.
 

I know, I know. I need more practice.

-- 
Stephen Turner, Cambridge, UKhttp://homepage.ntlworld.com/adelie/stephen/
This is Henman's 8th Wimbledon, and he's only lost 7 matches. BBC, 2/Jul/01




Re: TPR0 Final Results

2002-02-16 Thread Jerome Quelin

On Samedi 16 Février 2002 14:37, Stephen Turner wrote :
 On Sun, 17 Feb 2002 [EMAIL PROTECTED] wrote:
  Oh deary me, Stephen, you beat Spiff by two hours but forgot
  that map{$expr}list could be shortened to map$expr,list.
  And, in the last game, you forgot that for could go at the end.

 I know, I know. I need more practice.

Then you'll be able to practice soon: next tournament for tpr1 begins march 
the 1st, and I don't think you'll find a module to solve this one. But who 
knows? ;)
This may be too soon, but we are to stick with tpr issues. We hope that 
you'll submit anyway.

Jerome
-- 
[EMAIL PROTECTED]



Re: TPR0 Final Results

2002-02-16 Thread Bill -OSX- Jones

On Friday, February 15, 2002, at 06:47  PM, Stephen Turner wrote:
 #!perl -l
 use POSIX;print~~strtol pop,36

 Well, I repeat my challenge. Can anyone beat Karsten's 46 without using
 POSIX?

Hmm, maybe not...

I can get to 55 or so... But here is an expanded solution -

#!perl
while (DATA) {
   chomp;
   s/^\s+//;  # Delete whitespace...
   s/\s+$//;

   split //; # Create an array of characters

   for (@_) { # Walking thru we get position Power

s#\D#-55+ord$#e; # If we have Letters then make Numbers

$z=36*$z+$_; # Make the Base Conversion to Base 10
   }

   print$z ;

   $z = 0; # Reset the char to 0
}

=pod
   Test Data results in:
   375 159 625047 718501
   respectively...
=cut

__END__
AF
4F
DEAF
FEED


Obviously A LOT of room for shortening!  Which, of course,
is left to those interested in such matters :)

Cheers!  :]
_Sx
  ('-Sx- IUDICIUM
  //\   Have Computer -
  v_/_Will Hack...




Re: TPR0 Final Results

2002-02-16 Thread Stephen Turner

On Sat, 16 Feb 2002, Jerome Quelin wrote:
 
 Then you'll be able to practice soon: next tournament for tpr1 begins march 
 the 1st [...]
 This may be too soon, but we are to stick with tpr issues. We hope that 
 you'll submit anyway.
 

The sooner the better!

-- 
Stephen Turner, Cambridge, UKhttp://homepage.ntlworld.com/adelie/stephen/
This is Henman's 8th Wimbledon, and he's only lost 7 matches. BBC, 2/Jul/01




Re: TPR0 Final Results

2002-02-15 Thread Matthew Byng-Maddick

On Fri, Feb 15, 2002 at 06:16:48PM +0100, Jerome Quelin wrote:
 Yep. And that was very too much tiping when saying he gains 2 chars when 
 using -e flag since -M is the (only?) flag that can't be on the shebang line 
^^^
no, -T too

MBM

-- 
Matthew Byng-Maddick [EMAIL PROTECTED]   http://colondot.net/



Re: TPR0 Final Results

2002-02-15 Thread Stephen Turner

On Fri, 15 Feb 2002, Matthew Byng-Maddick wrote:

 On Fri, Feb 15, 2002 at 06:16:48PM +0100, Jerome Quelin wrote:
  Yep. And that was very too much tiping when saying he gains 2 chars when 
  using -e flag since -M is the (only?) flag that can't be on the shebang line 
 ^^^
 no, -T too
 

-T can appear on the #! lang, I believe.

Although I've never made it work under Windows. Does anyone know anything
about this?

Next puzzle: come up with a golf problem for which -T is a plausible
approach. :-)

-- 
Stephen Turner, Cambridge, UKhttp://homepage.ntlworld.com/adelie/stephen/
This is Henman's 8th Wimbledon, and he's only lost 7 matches. BBC, 2/Jul/01





RE: TPR0 Final Results

2002-02-15 Thread Jeff 'japhy' Pinyan

On Feb 15, Ala Qumsieh said:

Japhy writes:

   -l -MPOSIX print~~strtol pop,36

Doesn't work except on command line:

Ah, of course.

-- 
Jeff japhy Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for Regular Expressions in Perl published by Manning, in 2002 **
stu what does y/// stand for?  tenderpuss why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]




Re: TPR0 Final Results

2002-02-15 Thread F . Xavier Noria

On Fri, 15 Feb 2002 18:27:16 +0100
F. Xavier Noria [EMAIL PROTECTED] wrote:

: I learned that during these days (among a lot of other things). I
: thought the shebang meant pass to the executable plus flags the content
: of the rest of the file as if it was called from the shell prompt, but
: this turned to be false... do you know the exact actual meaning? I saw
: no mention of that exception (if it is so) in perldoc perlrun, do you
: know if is it documented somewhere?

Aha, is documented in perldiag:

   Too late for -%s option
   (X) The #! line (or local equivalent) in a Perl script
   contains the -M or -m option.  This is an error
   because -M and -m options are not intended for use
   inside scripts.  Use the use pragma instead.

So it seems that the shell invokes perl with the flag and perl itself
does not handle it. Where is the difference from the perl's view of the
execution? Why -M and -m options are not intended for use inside
scripts?

-- fxn




Re: TPR0 Final Results

2002-02-15 Thread John W. Krahn

Jeff 'Japhy' Pinyan wrote:
 
 On Feb 15, Dave Hoover said:
 
 Nine players ended up with the winning 33 stroke solution, but Tim
 submitted it first.  Unfortunately, this hole had a solution that
 was not very golfish, but did reward those willing to dig through
 some documentation on the core Perl modules.  Here is the winning
 solution:
 
 #!perl -l
 use POSIX;print~~strtol pop,36
 
   -l -MPOSIX print~~strtol pop,36
 
 Heh, that's 31.  Probably what John Krahn had (since he boasted a similar
 method that cut out 2 chars).

From the command line you can write it this way:

perl -MPOSIX -leprint~~strtol+pop,36

You don't need the quotes because there is no whitespace so you get 31
strokes.


John
-- 
use Perl;
program
fulfillment



Re: TPR0 Final Results

2002-02-15 Thread Bart Lateur

On Fri, 15 Feb 2002 08:53:45 -0600, Dave Hoover wrote:

Here is the winning solution:

#!perl -l
use POSIX;print~~strtol pop,36

Boo, boo! 

What an anti-climax. Utterly boring.

-- 
Bart.



Re: TPR0 Final Results

2002-02-15 Thread Stephen Turner

On Sat, 16 Feb 2002, Bart Lateur wrote:

 On Fri, 15 Feb 2002 08:53:45 -0600, Dave Hoover wrote:
 
 Here is the winning solution:
 
 #!perl -l
 use POSIX;print~~strtol pop,36
 
 Boo, boo! 
 
 What an anti-climax. Utterly boring.
 

Well, I repeat my challenge. Can anyone beat Karsten's 46 without using
POSIX?

-- 
Stephen Turner, Cambridge, UKhttp://homepage.ntlworld.com/adelie/stephen/
This is Henman's 8th Wimbledon, and he's only lost 7 matches. BBC, 2/Jul/01




Re: TPR0 Final Results

2002-02-15 Thread Andrew . Savige

Stephen Turner wrote:
 Can someone explain to me why

 -l use POSIX;print strtol pop,36

 doesn't work? Where does the extra 0 come from?

To quote myself to Dave and Jerome:

BTW, because I felt you were already inundated with queries about
it, I did not bother you with what seems to be a Perl bug that
prevents a 32-stroke solution from working. I was too lazy to
analyse it (instead, I trusted that Ton would, but since he has
not posted 32, I guess it cannot be worked around).

#!/usr/bin/perl -l
use POSIX;print strtol pop,36

I think this should work, but it prints a spurious trailing zero.

These two programs perhaps make it a little clearer:
  c4.pl:
  use POSIX;print strtol(pop,36)
  c5.pl:
  use POSIX;print 0+strtol(pop,36)
When you run:
  perl c4.pl 9
it prints 90, while:
  perl c5.pl 9
prints 9. Go figure!

Maybe Perl golf is useful, after all -- as a QA tool to find
Perl bugs. :)

/-\ndrew



Re: TPR0 Final Results

2002-02-15 Thread Andrew . Savige

Rick Klement wrote:
 A modest suggestion for perl golf: no modules allowed.

If it's any consolation, Rick, I think most serious golfers
(well, me, at least;-) recognize those golfers who shot 46
and 47 without using any modules or external commands.
I tried hard, but could not break 50. :-( I would like to
congratulate all the golfers on 46 and 47 (especially Spiff).

/-\ndrew



Re: TPR0 Final Results

2002-02-15 Thread Matthew Byng-Maddick

On Fri, Feb 15, 2002 at 05:47:14PM +, Stephen Turner wrote:
 On Fri, 15 Feb 2002, Matthew Byng-Maddick wrote:
  no, -T too
 -T can appear on the #! lang, I believe.

| mbm@full-stop:~$ perl test.pl 
| Too late for -T option at test.pl line 1.
| mbm@full-stop:~$ cat test.pl 
| #!perl -wT
| print hello, world\n

I've never seen it work.

 Although I've never made it work under Windows. Does anyone know anything
 about this?

I've yet to see it work under a UNIX system either.

MBM

-- 
Matthew Byng-Maddick [EMAIL PROTECTED]   http://colondot.net/



Re: TPR0 Final Results

2002-02-15 Thread Ronald J Kimball

On Sat, Feb 16, 2002 at 11:10:41AM +1100, [EMAIL PROTECTED] wrote:
 Stephen Turner wrote:
  Can someone explain to me why
 
  -l use POSIX;print strtol pop,36
 
  doesn't work? Where does the extra 0 come from?
 
 To quote myself to Dave and Jerome:
 
 BTW, because I felt you were already inundated with queries about
 it, I did not bother you with what seems to be a Perl bug that
 prevents a 32-stroke solution from working. I was too lazy to
 analyse it (instead, I trusted that Ton would, but since he has
 not posted 32, I guess it cannot be worked around).
 
 #!/usr/bin/perl -l
 use POSIX;print strtol pop,36
 
 I think this should work, but it prints a spurious trailing zero.

RTFM.

   strtol  String to (long) integer translation.  Returns the
   parsed number and the number of characters in the
   unparsed portion of the string

Ronald