hi

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 anyone help me in this????


--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
pradeep [ Di, 13 September 2011 16:00 ] [ ID #2064341 ]

Re: hi

On Tue, Sep 13, 2011 at 07:00:42AM -0700, pradeep wrote:
> 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 anyone help me in this????

Unlikely, unless you are a bit more specific about what you are trying to do.

And even then, it's hard to help you to improve your code if you don't show
it.

--
Paul Johnson - paul [at] pjcj.net
http://www.pjcj.net

--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
Paul Johnson [ Mi, 14 September 2011 13:17 ] [ ID #2064344 ]

Re: hi

On Tue, Sep 13, 2011 at 10:00 AM, pradeep <epradeep.kumar1439 [at] gmail.com> wrote:
> Can anyone help me in this????

Of course we can!

#/usr/bin/perl

use strict;
use warnings;

my $input = <>;

chomp $input;

if($input eq '1,2,3,4,5,6')
{
print <<'EOF';
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
EOF
}

__END__

You're welcome. <_<

Regards,


--
Brandon McCaig <http://www.bamccaig.com/> <bamccaig [at] gmail.com>
V zrna gur orfg jvgu jung V fnl. Vg qbrfa'g nyjnlf fbhaq gung jnl.
Castopulence Software <http://www.castopulence.org/> <bamccaig [at] castopulence.org>

--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
Brandon McCaig [ Mi, 14 September 2011 18:35 ] [ ID #2064347 ]

Re: hi

On Wed, Sep 14, 2011 at 12:35 PM, Brandon McCaig <bamccaig [at] gmail.com> wrote:
> #/usr/bin/perl

Silly me, I forgot the bang.

--- a Wed Sep 14 12:38:40 2011
+++ b Wed Sep 14 12:38:46 2011
[at] [at] -1,4 +1,4 [at] [at]
-#/usr/bin/perl
+#!/usr/bin/perl

use strict;
use warnings;


--
Brandon McCaig <http://www.bamccaig.com/> <bamccaig [at] gmail.com>
V zrna gur orfg jvgu jung V fnl. Vg qbrfa'g nyjnlf fbhaq gung jnl.
Castopulence Software <http://www.castopulence.org/> <bamccaig [at] castopulence.org>

--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
Brandon McCaig [ Mi, 14 September 2011 18:40 ] [ ID #2064348 ]

Re: hi

--001485f91ece2328e504acf843d0
Content-Type: text/plain; charset=ISO-8859-1

There is a pm called Math::Combinatorics (
http://search.cpan.org/~allenday/Math-Combinatorics-0.09/lib /Math/Combinatorics.pm
)

It is really helpful to get the combinations without repetition. Then you
just need to process the results to get the output you need, I mean with the
"," and "-".

I hope this can help you.

2011/9/14 Brandon McCaig <bamccaig [at] gmail.com>

> On Wed, Sep 14, 2011 at 12:35 PM, Brandon McCaig <bamccaig [at] gmail.com>
> wrote:
> > #/usr/bin/perl
>
> Silly me, I forgot the bang.
>
> --- a Wed Sep 14 12:38:40 2011
> +++ b Wed Sep 14 12:38:46 2011
> [at] [at] -1,4 +1,4 [at] [at]
> -#/usr/bin/perl
> +#!/usr/bin/perl
>
> use strict;
> use warnings;
>
>
> --
> Brandon McCaig <http://www.bamccaig.com/> <bamccaig [at] gmail.com>
> V zrna gur orfg jvgu jung V fnl. Vg qbrfa'g nyjnlf fbhaq gung jnl.
> Castopulence Software <http://www.castopulence.org/> <
> bamccaig [at] castopulence.org>
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
> For additional commands, e-mail: beginners-help [at] perl.org
> http://learn.perl.org/
>
>
>

--001485f91ece2328e504acf843d0--
Francisco Rivas [ Do, 15 September 2011 12:22 ] [ ID #2064389 ]
Perl » gmane.comp.lang.perl.beginners » hi

Vorheriges Thema: Help, About Global variable.
Nächstes Thema: error print on closed file handle