All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars
 perplexus dot info

 Tic Tac Toe (Posted on 2002-09-27)
A computer science teacher poses his students a problem.

"I want you write a computer program that plays tic-tac-toe legally and runs through ALL the possible combinations of the game, and finds out the total."

The students settle down to work..

An hour later, a student gets up and proclaims "I've got it! The number of possible combinations in a game is 344,242."

At which point another student quickly replies, "I haven't finished yet, but I'm sure Fred made a mistake in his program."

Why?

(Tic Tac Toe = Noughts and Crosses)

Comments: ( Back to comment list | You must be logged in to post comments.)
 re: Solution | Comment 5 of 12 |
(In reply to Solution by Jacob Fugal)

Jim and Jacob are looking at arrangements of X's and O's on the board, but not at what the assignment was. The computer is supposed to emulate playing every possible game, so consider what is involved. Player 1 (X) picks one of the nine spaces and claims it. Player 2 (O) picks one of the eight that are left, etc.

There are 9! = 9*8*7*6*5*4*3*2*1 = 362880 possible sequences, but not all of them are played out to the end. This is a little greater than "Fred's" solution, and so Jacob's approach will not provide us with a easy way to discredit "Fred."

No, friedlinguini's approach is the correct one. When we realize that 1-2-3-4-5-6-7-8-9 and 3-2-1-6-5-4-9-8-7 are separate sequences, but equivalent games due to reflection, and that they each have another 3 equivalents by rotation, and if every possible sequence has seven equivalents then every legal sequence must have seven equivalents, so the number of legal sequences must be divisible by 8.
 Posted by TomM on 2002-09-29 01:55:35

 Search: Search body:
Forums (0)