[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Recursion, anyone?



At 03:49 PM 4/11/01, you wrote:
>On Wed, Apr 11, 2001 at 03:08:58PM -0400, Kort, Eric wrote:
> > Anyone care to improve on my first attempt?  If someone reduces this to a
> > one-liner, I promise never to post again!
>
>I only managed a two-liners. Drat. ;)
>
>#!/usr/bin/perl
>@e=(A..Z,a..z,0..9,'-');@i=(0)x shift;$\="\n";while($f=1){print@e[@i];
>map{$f&&((++$i[$_]>@e?$i[$_]:$f)=0)}0..@i-1;$f&&exit;}
>
>
>Joy,
>`/anick


Here's my two-liner, a bunch longer than yours.  I tried a mathematical 
approach.

$m=shift;@a=(a..z,1..9,'-');for($i=0;$i<$#a**$m;$i++){$p=$i;for($o=0;
$o<$m;$o++){print$a[$p%$#a] if $p;$p=int($p/$#a);}print"\n";}

Don't pick on me too much, this is my first short-short attempt. :)

Back to work for me.

-e




>--
>"Try everything once except incest and folk dancing."
>                                         - Sir Thomas Beecham
>
>==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
>==== Send email to <fwp-request@technofile.org> with message _body_
>====   unsubscribe


-- 
How Microsoft would like to deal with Linux:

"Windows has detected a faster, superior, more efficient operating system on
your computer.  Do you wish to delete it?"
[yes]   [yes]


*------------------------------------------------------*
*    eric von zee     *------* tritech marketing inc.  *
*   web  developer    *------* evonzee@tritechnet.com  *
*  www.tritechnet.com *------*   630.654.0170 x 129    *
*------------------------------------------------------*


==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe