Hi again
I've got this (edit: thx to hdb):
#!/usr/bin/perl -w use strict; use warnings; use Algorithm::Combinatorics qw(combinations); my $rep = 10; my @data = 1..$rep; my $iter = combinations( \@data, 4 ); while( my $p = $iter->next ) { my ( $w, $x, $y, $z ) = @$p; next unless $w-2*$x+$y or $x-2*$y+$z; print "$w, $x, $y, $z\n"; }
& I would love to add something that would tell me how many combinations it has gone through before it's done. A percentage would be ideal. I tried my @all_combinations = combinations(\@data, $k); & then something like $#$p/$#all_combinations which got me a number, but it was the same on every line, I suppose because there are always the same number of elements in @$p. I also don't really want to create a new array to put the combinations in because I'm only planning to use it for seeing how close I am to being done.
In reply to how to add a counter by crunch_this!
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |