### comment on

 Need Help??

#!/usr/bin/env perl use strict; use warnings; use Algorithm::Loops qw(NestedLoops); use Text::Levenshtein::XS qw(distance); my @chars = qw(A M N U); my \$depth = 5; # We're taking "five at a time" from A, M, N, U. my \$min_dist = 3; # We need a minimum difference of 3 characters. my @strings; NestedLoops( [ ([@chars]) x \$depth ], sub { push @strings, join('', @_) }, ); my \$count = 0; foreach my \$left (@strings) { foreach my \$right (@strings) { if (distance(\$left, \$right) >= \$min_dist) { print ++\$count, ": \$left <=> \$right\n"; } } } print "\n\$count pairs with minimum difference of \$min_dist from a set +of ", scalar(@chars), " characters taken \$depth at a time.\n";

Algorithm::Loops and Text::Levenshtein make it easy to generate the list of hits.

Output:

1: AAAAA <=> AAMMM 2: AAAAA <=> AAMMN 3: AAAAA <=> AAMMU 4: AAAAA <=> AAMNM 5: AAAAA <=> AAMNN .... # many lines deleted 917168: UUUUU <=> UUNMM 917169: UUUUU <=> UUNMN 917170: UUUUU <=> UUNNA 917171: UUUUU <=> UUNNM 917172: UUUUU <=> UUNNN 917172 pairs with minimum difference of 3 from a set of 4 characters t +aken 5 at a time.

Dave

In reply to Re^3: 10 x 10 table of values by davido
in thread table of values by dnamonk

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 or How to display code and escape characters are good places to start.

Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2022-05-28 20:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
Do you prefer to work remotely?

Results (101 votes). Check out past polls.

Notices?