I have the data as below:
1,1000,2000,3000 999,1999,2999,3999 [m1,m2,m3,m4 n1,n2,n3,n4]
And the number of 1st and 2nd set will vary in the every line but there will be equal number of numbers in both the set.
I am successful in collecting them in the following simple manner as below:
999-1000, 1999-2000, 2999-3000 [n1-m2, n2-m3, n3-m4]
Basically, I collect all the start nos as 1,1000,2000 and 3000 and end nos in 999,1999,2999,3999 two arrays.
Expand|Select|Wrap|Line Numbers
- $starts = "1,1000,2000,3000";
- $ends = "999,1999,2999,3999";
- my @test_starts = split (/,/, $starts);
- my @test_ends = split (/,/, $ends);
- $size= @starts - 1;
- for (my $i = 0; $i < $size; $i++)
- {
- print "$test_end[i] - $test_start[i+1]\n";
- }
Now I want to add all the possible ways as below:
999-1000, 1999-2000, 2999-3000 [n1-m2, n2-m3, n3-m4]
as well as
999-2000, 999-3000 [n1-m3, n1-m4]
I am bit confused as this might require any recursive. Please let me know any method to solve the issue. Thanks.