Perl tuning/speed question: all subsets of a set of length k -- keeping the inital order
Author Message
Perl tuning/speed question: all subsets of a set of length k -- keeping the inital order

Dear Perl champs,

I got some problem, and I wonder how close to the speed of C  I can get
with the following problem. I appreciate all your input a lot.

k is an integer between 1 and 25.

(e.g. keep the original order of the words)
So if k=2, e.g. the result would ne
This is
This a
This sample
This and
This nothing
This else
is a
is sample
is and
... etc. ..
nothing else

Thanks a lot and looking foward to your suggestions.
Armin

Fri, 30 Nov 2001 03:00:00 GMT
Perl tuning/speed question: all subsets of a set of length k -- keeping the inital order
[Posted and a courtesy copy mailed.]

Quote:
> I got some problem, and I wonder how close to the speed of C  I can get
> with the following problem. I appreciate all your input a lot.

I have a solution, not tuned for speed, and certainly not compared to
the speed of C.

Quote:

> k is an integer between 1 and 25.

> (e.g. keep the original order of the words)
> So if k=2, e.g. the result would ne
> This is
> This a
> This sample
> This and
> This nothing
> This else
> is a
> is sample
> is and
> .... etc. ..
> nothing else

#!/usr/local/bin/perl -w
use strict;

# Return an ordered list of the ordered combinations of \$k
# integers out of \$n integers, starting from 0.
sub combs {
my (\$k, \$n) = (shift, shift);

combs(\$k - 1, \$n,

Quote:
}

--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/

Fri, 30 Nov 2001 03:00:00 GMT
Perl tuning/speed question: all subsets of a set of length k -- keeping the inital order

: Subject: Perl tuning/speed question: all subsets of a set of length k -- keeping

: I got some problem, and I wonder how close to the speed of C  I can get
: with the following problem. I appreciate all your input a lot.

Where is the Perl code that your Subject says you want "tuned"?

I think you forgot to include it...

--