Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (6)
As of 2024-04-23 20:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found