String-MMM
view release on metacpan or search on metacpan
void
match_strings(hidden,target,colors)
char *hidden;
char *target;
int colors;
INIT:
int i;
int blacks = 0;
int whites = 0;
int colors_in_string_h[colors], colors_in_string_t[colors];
PPCODE:
for ( i = 0; i < colors; i++ ) {
colors_in_string_h[i] = colors_in_string_t[i] = 0;
}
for ( i = 0; i < strlen( hidden ); i++ ) {
if ( hidden[i] == target[i] ) {
blacks++;
} else {
colors_in_string_h[hidden[i] - 'A']++;
colors_in_string_t[target[i] - 'A']++;
}
void
s_match_strings(hidden,target,colors)
char *hidden;
char *target;
int colors;
INIT:
int i;
int blacks = 0;
int whites = 0;
int colors_in_string_h[colors], colors_in_string_t[colors];
PPCODE:
for ( i = 0; i < colors; i++ ) {
colors_in_string_h[i] = colors_in_string_t[i] = 0;
}
for ( i = 0; i < strlen( hidden ); i++ ) {
if ( hidden[i] == target[i] ) {
blacks++;
} else {
colors_in_string_h[hidden[i] - 'A']++;
colors_in_string_t[target[i] - 'A']++;
}
void
match_strings_a(hidden,target)
char *hidden;
char *target;
INIT:
int i;
int blacks = 0;
int whites = 0;
int colors = 26;
int colors_in_string_h[colors], colors_in_string_t[colors];
PPCODE:
for ( i = 0; i < colors; i++ ) {
colors_in_string_h[i] = colors_in_string_t[i] = 0;
}
for ( i = 0; i < strlen( hidden ); i++ ) {
if ( hidden[i] == target[i] ) {
blacks++;
} else {
colors_in_string_h[hidden[i] - 'a']++;
colors_in_string_t[target[i] - 'a']++;
}
void
match_arrays(hidden_ref,target_ref, colors)
SV* hidden_ref;
SV* target_ref;
unsigned int colors;
INIT:
int i;
int blacks = 0;
int whites = 0;
int colors_in_string_h[colors], colors_in_string_t[colors];
PPCODE:
AV* hidden;
AV* target;
hidden = (AV*) SvRV(hidden_ref);
target = (AV*) SvRV(target_ref);
for ( i = 0; i < colors; i++ ) {
colors_in_string_h[i] = colors_in_string_t[i] = 0;
}
for ( i = 0; i <= av_len( hidden ); i++ ) {
int hidden_val = SvIV(*av_fetch(hidden,i,0));
int target_val = SvIV(*av_fetch(target,i,0));
( run in 0.444 second using v1.01-cache-2.11-cpan-5511b514fd6 )