- SEE ALSO
- DEVELOPMENT AND BUGS
- COPYRIGHT AND LICENSE
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 contains number of blacks, $result 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.
Matches 'A'-based strings (from 'A....A' to 'chr($colors)...chr($colors)', with an alphabet of size $colors. Returns a string with "%db%dw" as format. It happens that it's useful that way and slow to do it otherwise
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. Why would you? Nobody knows. But I don't want to pull a Bill Gates here.
This module is used by some algorithms in Algorithm::MasterMind.
Needs a C compiler to install.
Juan J. Merelo Guervós, <email@example.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:
- Around line 96:
Non-ASCII character seen before =encoding in 'Guervós,'. Assuming UTF-8