in reply to how to add a counter
#!/usr/bin/perl use warnings; use strict; use Algorithm::Combinatorics qw(combinations); my $rep = 10; my @data = 1 .. $rep; my $size = 4; my $iter = combinations(\@data, $size); my $maxcount = 1; $maxcount *= $_ for 1 + $rep - $size .. $rep; $maxcount /= $_ for 2 .. $size; my $count = 1; while (my ($w, $x, $y, $z) = @{ $iter->next // [] }) { $count++; next unless $w-2*$x+$y or $x-2*$y+$z; print $count/$maxcount, "\t$w, $x, $y, $z\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: how to add a counter
by crunch_this! (Acolyte) on May 30, 2013 at 03:24 UTC |