Created
May 1, 2015 22:19
-
-
Save planetguru/a62356b38ffdf74ddea2 to your computer and use it in GitHub Desktop.
Mastermind solver
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <stdio.h> | |
int * score( int[], int[] ); | |
int main( void ){ | |
int result[2]; | |
int codeword[4] = {2,2,2,3}; | |
int testword[4] = {3,3,1,2}; | |
result[2] = solve(codeword, testword); | |
printf("\nB: %d, W: %d\n",result[0],result[1]); | |
return 1; | |
} | |
int * solve( int testword[], int codeword[]){ | |
int * hint[2]={0,0}; | |
int i; | |
for( i=0; i < 4; i++ ){ | |
if(testword[i] == codedword[i]){ | |
hint[0]++; | |
} | |
} | |
for( i=0; i < testword.length, i!=j; i++ ){ | |
if(testword[i]==codedword[i]){ | |
hint[1]++; | |
} | |
} | |
return * hint; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment