furthermore, in your example the elements from the "alphabet" always only appear once
'a{b,c}d{e,fg{,h,ij}k}l{,m{n,o}}';
I suppose that is not a given, but this might guaranty a unique solution.
OTOH if characters can be repeated I'd bet that multiple solutions are possible.
Please clarify.
update
for instance all these glob expressions are equivalent ( I removed the variations where {,a} and {a,} were swapped)
use v5.12;
use warnings;
use Data::Dump;
use Test::More;
test (
[ <{a,aa}> ],
[ <{,a}{a}> ],
[ <{a}{,a}> ],
[ <a{,a}> ],
[ <{,a}a> ],
);
sub test {
my @g = @_;
my (%h1,%h2);
for my $i (0..$#g) {
for my $j ($i+1..$#g) {
is_deeply(
[sort @{$g[$i]}],
[sort @{$g[$j]}],
"$i,$j")
or ddx $g[$i],$g[$j];
}
}
}
done_testing;
|