# how to get this type of combinations???

Discussion in 'Perl Misc' started by pradeep, Sep 13, 2011.

Hi,
I do have a doubt ,
Input :
1,2,3,4,5,6
output :
1-2,3-4,5-6
1-2,3-5,4-6
1-2,3-6,4-5

1-3,2-4,5-6
1-3,2-5,4-6
1-3,2-6,4-5

1-4,2-3,5-6
1-4,2-5,3-6
1-4,2-6,3-5

1-5,2-3,4-6
1-5,2-4,3-6
1-5,2-6,3-4

1-6,2-3,4-5
1-6,2-4,3-5
1-6,2-5,3-4

Can you help me in this????

2. ### RedGrittyBrickGuest

> Hi,
> I do have a doubt ,
> Input :
> 1,2,3,4,5,6
> output :
> 1-2,3-4,5-6
> 1-2,3-5,4-6
> 1-2,3-6,4-5
>
> 1-3,2-4,5-6
> 1-3,2-5,4-6
> 1-3,2-6,4-5
>
> 1-4,2-3,5-6
> 1-4,2-5,3-6
> 1-4,2-6,3-5
>
> 1-5,2-3,4-6
> 1-5,2-4,3-6
> 1-5,2-6,3-4
>
> 1-6,2-3,4-5
> 1-6,2-4,3-5
> 1-6,2-5,3-4
>
> Can you help me in this????

Yes.

0) Read posting guidelines that are posted here every few days.

http://www.catb.org/~esr/faqs/smart-questions.html#homework - it really
is useful.

2) Think of an alogorithm. Implement in concise Perl. Cut & Paste code +
output here. Describe difference between actual and desired output.

3) Think of keywords (Combinations? Permutations?). Search CPAN for
modules. Read descriptions. Write concise Perl to use chosen module. Cut
& Paste code and output here. Describe difference between actual and
desired output.

--
RGB

RedGrittyBrick, Sep 13, 2011

3. ### Jürgen ExnerGuest

>I do have a doubt ,

You have a doubt about what?

>Input :
> 1,2,3,4,5,6

Well, ok, so I guess this is a list of 5 numbers?

>output :
>1-2,3-4,5-6
>1-2,3-5,4-6
>1-2,3-6,4-5

[...]

Ok, so you are getting this output.

>Can you help me in this????

yet.
Not to mention that you forgot to post your code and the desired output.
Therefore there is no way for us to tell what is wrong with your code.

jue

Jürgen Exner, Sep 14, 2011
4. ### Randal L. SchwartzGuest

Tad> 4) Do NOT search the internet for the email address of someone
Tad> who looks like they know Perl and then send them email containing

Oh, you too?

Ok, I'm ignoring the loon then.

[mail deleted]

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.posterous.com/ for Smalltalk discussion

Randal L. Schwartz, Sep 15, 2011