I have the task of writing a function to determine the outcome of a game of tictactoe, i at first thought use a couple of for loops but that proved pointless, and then the only way i could think of was to write an if...elif...else statement for each row, column and diagonal. which isnt very impressive, so can anyone show me, or hint at a way to do this?
below is exactly what it says on the site.
In the pencil-and-paper game, Tic-tac-toe, 2 players take turns to mark 'X' and 'O' on a board of 3x3 squares. The player who succeeds in marking 3 successive 'X' or 'O' in vertical, horizontal or diagonal stripe wins the game. Write a function that determines the outcome of a tic-tac-toe game.
Examples
>>> tictactoe([('X', ' ', 'O'),
(' ', 'O', 'O'),
('X', 'X', 'X') ])
"'X' wins (horizontal)."
>>> tictactoe([('X', 'O', 'X'),
... ('O', 'X', 'O'),
... ('O', 'X', 'O') ])
'Draw.'
>>> tictactoe([('X', 'O', 'O'),
... ('X', 'O', ' '),
... ('O', 'X', ' ') ])
"'O' wins (diagonal)."
>>> tictactoe([('X', 'O', 'X'),
... ('O', 'O', 'X'),
... ('O', 'X', 'X') ])
"'X' wins (vertical)."
Help much appreciated.