in reply to Re^2: Challenge: Generate a glob patterns from a word list
in thread Challenge: Generate a glob patterns from a word list
'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.
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;
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
|
|---|