title: MasterMind game in C
body: <p>I have this as my homework. Have a bit of trouble coding it. I am using C as the language.</p>
  
  <p>Question:</p>
  
  <blockquote>
    <p>Mastermind is a game of two players. In the beginning, first player decides a secret key, which is a sequence (s1,s2,...sk) where 0 &lt; si &lt;= n, Then second player makes guesses in rounds, where each guess is of form (g1,g2, ...gk), and after each guess first player calculates the score for the guess. Score for a guess is equal to number of i's for which we have gi = si.</p>
    
    <p>For example if the secret key is (4,2,5,3,1) and the guess is (1,2,3,7,1),then the score is 2, because g2 = s2 and g5 = s5. </p>
    
    <p>Given a sequence of guesses, and scores for each guess, your program must decide if there exists at least one secret key that generates those exact scores.</p>
  </blockquote>
  
  <p>Input:</p>
  
  <blockquote>
    <p>First line of input contains a single integer C (1 &lt;=C &lt;= 100). C test-cases follow. First line of each test-case contains three integers n,k and q. (1 &lt;=n,k &lt;=11, 1&lt;=q&lt;=8). Next q lines contain the guesses.</p>
    
    <p>Each guess consists of k integers gi,1, gi,2,....gi,k separated by a single space, followed by the score for the guess bi (1 &lt;= gi,j &lt;=n for all 1 &lt;=i &lt;=q, 1 &lt;=j &lt;=k; and 0 &lt;= bi &lt;=k )</p>
  </blockquote>
  
  <p>Output:</p>
  
  <blockquote>
    <p>For each test-case, output "Yes" (without quotes), if there exists at least a secret key which generates those exact scores, otherwise output "No".</p>
  </blockquote>
  
  <p>The code I wrote is this: </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  #include &lt;stdarg.h&gt;  
  #include &lt;stdlib.h&gt;
  #include &lt;stdbool.h&gt;
  
  typedef struct set_t{    
      int count;     
      void **values; 
  } *SetRef;
  
  SetRef set_create(void *values, ...); 
  int  set_count(SetRef this);
  bool set_contains(SetRef this, void *value);  
  int rscore(SetRef set1, void *value, int score);
  
  
  int main(int argc,char **argv )
  {
      int t = 0, n = 0 ,k = 0,q = 0, score = 0;
      char ch;
      int arr1[n];
      int arr2[n];
      printf("Please enter the number of test cases(between 1 to 100):");
      scanf("%d",&amp;t);
      printf("\n");
      for ( int i = 1; i&lt;=t;i++)
      {
          printf("Please enter values of n,k, q:");
          scanf("%i %i %i",&amp;n, &amp;k, &amp;q);
  
          printf("\n");
          printf("Enter the values of secret key");
          score = 0;
          for ( int c = 0 ; c &lt; n ; c++ )
          {
              scanf("%d",&amp;arr1[c]);
           }
          printf("\n");
          printf("Enter the values of guess");
              for ( int c = 0 ; c &lt; n ; c++ )
              {
                  scanf("%d",&amp;arr2[c]);
               }
  
          }
         SetRef set1 = set_create(&amp;arr1); 
         SetRef set2 = set_create(&amp;arr2); 
         for ( int i = 0; i &lt; set2-&gt;count; i++){
              void *val = set2-&gt;values[i]; 
              score = rscore(set1, val,score);
          }        
          if ( score == set1-&gt;count)
              printf("Yes");
          else
              printf("No");
          printf("\n");
      }
  }
  
  SetRef set_create(void *values, ...) 
  {   
      SetRef set = calloc(1, sizeof(struct set_t));    
      if (values)   
      {        
          int count = 1;     
           va_list args;       
           va_start(args, values);       
          while (va_arg(args, void *)) 
          {             
              count++;    
          }          
          va_end(args);       
          set-&gt;count = count;      
          set-&gt;values = calloc(count, sizeof(void *));      
          set-&gt;values[0] = values;    
          va_start(args, values);       
          int i = 1;         
          void *val;       
          while ((val = va_arg(args, void *)))
          {            
              set-&gt;values[i++] = val;      
          }       
          va_end(args);    
      }      
      return set; 
  }  
  int set_count(SetRef this) 
  {    
      return this-&gt;count; 
  } 
  bool set_contains(SetRef this, void *value) 
  {    
      for (int i = 0; i &lt; this-&gt;count; i++)
      {      
          if (value == this-&gt;values[i])   
              return true;   
      }    
      return false;
  }  
  
  int rscore(SetRef set1, void *value, int score){
      void *val = value;
      if (set_contains(set1, val))
          score ++;
      return score;
  }  
  </code></pre>
  
  <p>I have these errors: </p>
  
  <blockquote>
    <p>solution.cc:60:1: error: expected declaration before ‘}’ token</p>
  </blockquote>
  
  <p>Besides that, is my logic correct? Have I made any major mistakes?</p>
  
  <p>Not sure how to solve this. Need some guidance.</p>