You’re right, thanks! I forgot to include the OP’s code for sorting the path arrays according to number of elements. Node updated:
... @paths = sort { @$a <=> @$b } @paths; my @sets; push @sets, set(@$_) for @paths; my @filtered; ...
Now the output for your input data is as follows:
16:12 >perl 1681_SoPW.pl (Q R V) (C D V) (N P Q) (E T V X) (E N O P) (I N T U Z) (B D R W Z) (A N O X Z) (B L O R T) (D H S X Y) (D F J K O P T) (D J M R S T V) (B H J L N P U) (A B H P R V X) (C F L M T Y) (C I J L M O X Y) (D H I P S T V Y) (A B D F G O U W) (A C D E H J L N S Z) (D F G M O S U W Y) (A C G H J K P V Z) (E H K M N P T V) (F H I L O T V Z) 16:12 >
Update: Since sets contain no duplicate elements, it will be better to sort on number of elements after the arrays have been converted into sets:
... my @sets; push @sets, set(@$_) for @paths; @sets = sort { $a->size <=> $b->size } @sets; my @filtered; ...
Output:
17:06 >perl 1681_SoPW.pl (Q R V) (C D V) (N P Q) (E N O P) (E T V X) (D H S X Y) (I N T U Z) (B D R W Z) (A N O X Z) (B L O R T) (C F L M T Y) (B H J L N P U) (A B H P R V X) (D F J K O P T) (D J M R S T V) (E H K M N P T V) (F H I L O T V Z) (D H I P S T V Y) (A B D F G O U W) (C I J L M O X Y) (D F G M O S U W Y) (A C G H J K P V Z) (A C D E H J L N S Z) 17:08 >
Cheers,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
In reply to Re^3: Fast Way to find one array in second array
by Athanasius
in thread Fast Way to find one array in second array
by melmoth
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |