String::MMM - Perl XS for comparing (matching) strings MasterMind style
use String::MMM qw(:all); my @result = match_strings( 'AAAA', 'ABCD', 6 ); # 6 is alphabet size; # $result[0] contains number of blacks, $result[1] whites @result = match_strings_a( 'abcd', 'efgh' ); # alphabet size = 26; # should return 0,0 @result = match_arrays( [ 0,3,2,1], [0,0,1,2], 10 );
String comparison is a critical operation in MasterMind, and the fastest Perl implementation is not fast enough. This implementation can be up to an order of magnitude faster (depending on string size, of course).
Matches 'A'-based strings (from 'A....A' to 'chr($colors)...chr($colors)', with an alphabet of size $colors. Returns an array with the number of blacks and whites as first and second element. Length is not checked; comparison is done over the length of $hidden.
Same as above, with lowercase letters. Besides, $colors is assumed to be 26.
Same as above, with integer numbers. Just in case you need more than 26 symbols.
This module is used in some algorithms in Algorithm::MasterMind.
Needs a C compiler to install
Juan J. Merelo Guervós, <jjmerelo@gmail.com>
Copyright (C) 2013 by Juan J. Merelo Guervós
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.16.0 or, at your option, any later version of Perl 5 you may have available.
1 POD Error
The following errors were encountered while parsing the POD:
Non-ASCII character seen before =encoding in 'Guervós,'. Assuming UTF-8
To install String::MMM, copy and paste the appropriate command in to your terminal.
cpanm
cpanm String::MMM
CPAN shell
perl -MCPAN -e shell install String::MMM
For more information on module installation, please visit the detailed CPAN module installation guide.