use strict;
use warnings;
use Math::Combinatorics;
use List::Util qw( first );
my @A = 'A' .. 'Z';
my @B = 0 .. 9;
my $count = 0;
my $comb_A = Math::Combinatorics->new( count => 3, data => [@A] );
while( my @combo_A = $comb_A->next_combination ) {
my $comb_B = Math::Combinatorics->new( count => 2, data => [@B] );
INNER: while( my @combo_B = $comb_B->next_combination ) {
my %overlap;
@overlap{@combo_B} = ();
next INNER if first{ exists $overlap{$_} } @combo_A;
print join( ' ', @combo_A, @combo_B ), "\n";
$count++;
}
}
print "Whew, that resulted in $count result-producing iterations!\n";
##```
##
A B C 0 1
A B C 0 2
A B C 0 3
A B C 0 4
A B C 0 5
A B C 0 6
...
...
...
X Y Z 7 6
X Y Z 4 0
X Y Z 4 3
X Y Z 4 6
X Y Z 0 3
X Y Z 0 6
X Y Z 3 6
Whew, that resulted in 117000 result-producing iterations!
##
```

```
##
my %overlap;
@overlap{@combo_B} = ();
next INNER if first{ exists $overlap{$_} } @combo_A;
```