Learn AP Comp Sci

Problem of the Day

Monday, September 21, 2026


Problem:

A grid can be represented by a single list of values, given in order as shown:

0123
4567
891011
12131415

So the 4×4 grid

0001
0210
2110
2202

could be written as

0001021021102202

Now consider a tic-tac-toe game played on a 3×3 grid, where X represents a square marked by one player, 0 represents a square taken by the other player, and a dot . represents a square that hasn't been played yet. A player wins by marking three in a row (vertically, horizontally, or diagonally). Which of the following strings represent a game won by player X?

  1. XO.XOO.OX
  2. .XOXO..XO
  3. OX.OOXOX.
  4. ..XOXOXOO

Show solution:

The correct answer is d.

By examining that string, we can see that the third position in the first row, the second position in the second row, and the first position in the third row all have an X, indicating a win for that player.