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
b[48],c,k;//b is game board, c is column chosen by user, k keeps track of win state | |
/* | |
Win detection: | |
check four cells, each separated by n slots | |
AND (bitwise) them together: | |
If any of the cells are zero, the result is zero | |
If all the cells are one, the result is one | |
If all the cells are two, the result is two | |
If the cells contain a mix of ones and twos, the result is zero |
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
m,s,c,p; | |
main(v){ | |
for(;~(v=getchar());p=v) | |
if(m) | |
m=v^47||p^42; | |
else if(s) | |
s=v!=10; | |
else if(p^47) | |
c+=v^9&&v^10; |