Programming Mini-Challenge: TicTacToeBot
I've seen the programming challenges on ~comp as well as quite a few users who are interested in getting started with programming. I thought it would be interesting to post some 'mini-challenges'...
I've seen the programming challenges on ~comp as well as quite a few users who are interested in getting started with programming. I thought it would be interesting to post some 'mini-challenges' that all could have a go at. I'm certain that many of you might find these pretty straight forward, but I still think there's merit in sharing different approaches to simple problems, including weird-and-wonderful ones.
This is my first post and I'm a maths-guy who dabbles in programming, so I'm not promising anything mind-blowing. If these gain any sort of traction I'll post some more.
Starting of with...
TicTacToeBot
Info
You will be writing code for a programme that will check to see if a player has won a game of tic-tac-toe.
Input
The input will be 9 characters that denote the situation of each square on the grid.
- 'X' represents the X-player has moved on that square.
- 'O' represents the O-player has moved on that square.
- '#' represents that this square is empty.
Example:
|O| |X|
|X|X|O| The input for this grid will be O#XXXOO##
|O| | |
Output
The expected output is the character representing the winning player, or "#" if the game is not won.
(e.g. The expected output for the example above is '#' since no player has won)