The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

String::MMM - Perl XS for comparing (matching) strings MasterMind style

SYNOPSIS

  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 );

DESCRIPTION

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).

INTERFACE

match_strings ( $hidden, $target, $colors )

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.

match_strings_a ( $hidden, $target )

Same as above, with lowercase letters. Besides, $colors is assumed to be 26.

match_arrays ( $ref_to_hidden_array, $ref_to_hidden_target, $colors )

Same as above, with integer numbers. Just in case you need more than 26 symbols.

SEE ALSO

This module is used in some algorithms in Algorithm::MasterMind.

DEPENDENCIES

Needs a C compiler to install

AUTHOR

Juan J. Merelo Guervós, <jjmerelo@gmail.com>

COPYRIGHT AND LICENSE

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 78:

Non-ASCII character seen before =encoding in 'Guervós,'. Assuming UTF-8