Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: 10 x 10 table of values

by davido (Cardinal)
on Nov 29, 2021 at 17:22 UTC ( #11139229=note: print w/replies, xml ) Need Help??

in reply to table of values

I'm just curious, do you need the table, or do you need the list of those string pairs that have three or more differences? Of what significance is the 10x10 table? Really just satisfying my curiosity.


Replies are listed 'Best First'.
Re^2: 10 x 10 table of values
by dnamonk (Acolyte) on Nov 29, 2021 at 17:43 UTC
    Just a list should be enough. No need to plot the table. It is related to some biological experiment.

      #!/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.


      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.


        Great solution. Thanks a lot :)

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11139229]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2022-05-19 23:16 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (72 votes). Check out past polls.