Sweta
Do you believe anyone would ready your code?
At least it should be logical to debug..


On Mon, Apr 15, 2013 at 8:09 AM, Jugesh Sundram <jugeshsund...@gmail.com>wrote:

> Sweta,
>
> Congrats! Good news is your program works perfect. Bad news is I believe
> you have hard coded the problem which basically defeats the whole purpose
> of the competition. But this is only my opinion based on reading your
> program. I may be right / wrong !!
>
>
> On 14 April 2013 00:14, sweta sharma <sharma.sweta1...@gmail.com> wrote:
>
>> I wrote the following program . The program is giving correct output for
>> theinput file but the program isnt accepted...Its showing that its
>> Incorrect...Can someone please tell me what the problem is ?
>>
>> Source code :
>>
>> #include<stdio.h>
>> #include<ctype.h>
>> #include<stdlib.h>
>> struct p
>> {
>>   char board[4][4];
>> }*arr;
>> char check_horizontal(int i,int j,int *full)
>> {
>>
>>  
>> if(((arr[i].board[j][0]=='X')||(arr[i].board[j][0]=='T'))&&((arr[i].board[j][1]=='X')||(arr[i].board[j][1]=='T'))&&((arr[i].board[j][2]=='X')||(arr[i].board[j][2]=='T'))&&((arr[i].board[j][3]=='X')||(arr[i].board[j][3]=='T')))
>>   {
>>     return 'X';
>>   }
>>
>>  
>> if(((arr[i].board[j][0]=='O')||(arr[i].board[j][0]=='T'))&&((arr[i].board[j][1]=='O')||(arr[i].board[j][1]=='T'))&&((arr[i].board[j][2]=='O')||(arr[i].board[j][2]=='T'))&&((arr[i].board[j][3]=='O')||(arr[i].board[j][3]=='T')))
>>     return 'O';
>>
>> if((arr[i].board[j][0]=='.')||(arr[i].board[j][1]=='.')||(arr[i].board[j][2]=='.')||(arr[i].board[j][3]=='.'))
>>     *full=0;
>>    return 'N';
>> }
>> char check_vertical(int i,int j)
>> {
>>
>>  
>> if(((arr[i].board[0][j]=='X')||(arr[i].board[0][j]=='T'))&&((arr[i].board[1][j]=='X')||(arr[i].board[1][j]=='T'))&&((arr[i].board[2][j]=='X')||(arr[i].board[2][j]=='T'))&&((arr[i].board[3][j]=='X')||(arr[i].board[3][j]=='T')))
>>     return 'X';
>>
>>  
>> if(((arr[i].board[0][j]=='O')||(arr[i].board[0][j]=='T'))&&((arr[i].board[1][j]=='O')||(arr[i].board[1][j]=='T'))&&((arr[i].board[2][j]=='O')||(arr[i].board[2][j]=='T'))&&((arr[i].board[3][j]=='O')||(arr[i].board[3][j]=='T')))
>>    {
>>     return 'O';
>>   }
>>     return 'N';
>> }
>> char check_diagonal(int i,int j)
>> {
>>    if(j==0)
>>    {
>>
>>  
>> if(((arr[i].board[0][0]=='X')||(arr[i].board[0][0]=='T'))&&((arr[i].board[1][1]=='X')||(arr[i].board[1][1]=='T'))&&((arr[i].board[2][2]=='X')||(arr[i].board[2][2]=='T'))&&((arr[i].board[3][3]=='X')||(arr[i].board[3][3]=='T')))
>>     return 'X';
>>
>>  
>> if(((arr[i].board[0][0]=='O')||(arr[i].board[0][0]=='T'))&&((arr[i].board[1][1]=='O')||(arr[i].board[1][1]=='T'))&&((arr[i].board[2][2]=='O')||(arr[i].board[2][2]=='T'))&&((arr[i].board[3][3]=='O')||(arr[i].board[3][3]=='T')))
>>     return 'O';
>>    }
>>    if(j==3)
>>    {
>>
>> if(((arr[i].board[0][3]=='X')||(arr[i].board[0][3]=='T'))&&((arr[i].board[1][2]=='X')||(arr[i].board[1][2]=='T'))&&((arr[i].board[2][1]=='X')||(arr[i].board[2][1]=='T'))&&((arr[i].board[3][0]=='X')||(arr[i].board[3][0]=='T')))
>>     return 'X';
>>
>>  
>> if(((arr[i].board[0][3]=='O')||(arr[i].board[0][3]=='T'))&&((arr[i].board[1][2]=='O')||(arr[i].board[1][2]=='T'))&&((arr[i].board[2][1]=='O')||(arr[i].board[2][1]=='T'))&&((arr[i].board[3][0]=='O')||(arr[i].board[3][0]=='T')))
>>     return 'O';
>>    }
>>    return 'N';
>> }
>>
>> int main()
>> {
>>   FILE *fp,*f;
>>   fp=fopen("A-small-attempt0.in","r");
>>   f=fopen("out.txt","w");
>>   int n,i,j,k,draw,full=1;
>>   char ch;
>>   fscanf(fp,"%d\n",&n);
>>   arr=(struct p *)malloc(n*sizeof(struct p));
>>   for(i=0;i<n;i++)
>>   {
>>     for(j=0;j<4;j++)
>>     {
>>            arr[i].board[j][0]=fgetc(fp);
>>            arr[i].board[j][1]=fgetc(fp);
>>            arr[i].board[j][2]=fgetc(fp);
>>            arr[i].board[j][3]=fgetc(fp);
>>            ch=fgetc(fp);
>>
>>     }
>>     ch=fgetc(fp);
>>
>>   }
>>   for(i=0;i<n;i++)
>>   {
>>     draw=1;full=1;
>>     for(j=0;j<4;j++)
>>     {
>>       ch=check_horizontal(i,j,&full);
>>       if(ch=='X')
>>       {
>>          fprintf(f,"Case #%d: X won\n",i+1);
>>          break;
>>       }
>>       else if(ch=='O')
>>       {
>>          fprintf(f,"Case #%d: O won\n",i+1);
>>          break;
>>       }
>>       if(ch=='N')
>>       ch=check_vertical(i,j);
>>       if(ch=='X')
>>       {
>>          fprintf(f,"Case #%d: X won\n",i+1);
>>          break;
>>       }
>>       else if(ch=='O')
>>       {
>>          fprintf(f,"Case #%d: O won\n",i+1);
>>          break;
>>       }
>>       if((j==0)||(j==3))
>>       {
>>          ch=check_diagonal(i,j);
>>          if(ch=='X')
>>       {
>>          fprintf(f,"Case #%d: X won\n",i+1);
>>          break;
>>       }
>>       else if(ch=='O')
>>       {
>>          fprintf(f,"Case #%d: O won\n",i+1);
>>          break;
>>       }
>>       }
>>      }
>>      if((ch=='N')&&(full==1))
>>      {
>>         fprintf(f,"Case #%d: Draw\n",i+1);
>>      }
>>      else if ((full==0)&&(ch=='N'))
>>      {
>>         fprintf(f,"Case #%d: Game has not completed\n",i+1);
>>      }
>>    }
>>    fprintf(f,"\n");
>>    fclose(fp);
>>    fclose(f);
>>    return 0;
>> }
>>
>>
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Google Code Jam" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to google-code+unsubscr...@googlegroups.com.
>> To post to this group, send email to google-code@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/google-code/-/BwE3cKj4j04J.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>
> --
> Jugesh Sundram
> (jugeshsund...@gmail.com)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Code Jam" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to google-code+unsubscr...@googlegroups.com.
> To post to this group, send email to google-code@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-code+unsubscr...@googlegroups.com.
To post to this group, send email to google-code@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to