Beefy Boxes and Bandwidth Generously Provided by pair Networks Ovid
Welcome to the Monastery
 
PerlMonks  

Re: (Golf) Per Mutations

by arhuman (Vicar)
on May 03, 2001 at 22:09 UTC ( [id://77817]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to (Golf) Per Mutations

You're too good for me !
My best one is 85 (between curly brackets).
sub t{!@_&&print@r,"\n";for my $i(0..$#_){push@r,$_[$i];t(@_[0..$i-1], +@_[$i+1..$#_]);pop@r}}

"Only Bad Coders Badly Code In Perl" (OBC2IP)

Replies are listed 'Best First'.
Re: Re: (Golf) Per Mutations
by MeowChow (Vicar) on May 03, 2001 at 22:25 UTC
    Perhaps you'll be able to knock off a few more chars, since the sub isn't supposed to print anything - it only needs to return the data structure specified in the problem description.

    A brief reduction of this sub gives 79 chars though:

    sub t{!@_&&print@r,"\n";for my$i(1..@_){push@r,$_[$i-1];t(@_[0..$i-2,$ +i..$#_]);pop@r}}
       MeowChow                                   
                   s aamecha.s a..a\u$&owag.print
      Well done !
      But you should know that I leave a space between my and $i to get rid of a:
      'Missing $ on loop variable' error message with my Perl(5.0 patchlevel 5 subversion 3 on linux)

      "Only Bad Coders Badly Code In Perl" (OBC2IP)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://77817]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.