Let's play some code golf!
Given a tic-tac-toe board state (Example:)
|x|x|o| |x|o|x| |o|o|x|
Determine whether a game is a
cat. Your code should output any of these options given a state. The above game should output
Just to be clear: a win is defined as any 3
xs in a row (diagonal, horizontal, vertical). a lose is 3
os in a row, while a
cat game in none in a row.
To make things interesting, you get to determine your input structure for the state- which you must then explain. For instance
xxoxoxoox is a valid state as seen above where each of the characters is read from left to right, top to bottom.
[['x','x','o'],['x','o','x'],['o','o','x']] is the game in multidimensional array read in a similar way. While
0x1a9 which is hex for
110101001 might work as a suitable compression where
1 can be manipulated for
0 can be manipulated for
But those are just some ideas, I'm sure you might have many of your own.
- Your program must be able to accept any viable state.
- The form of input must be able to represent any state.
- The input cannot be redundant, meaning each cell must only appear in one location.
- "The win state must be determined from the board"
- Assume a complete board
losefor instance in the case 'xxxoooxxx'
Lowest character count wins