AP CSA FRQ Guide

2025 FRQ 4: SumOrSameGame

Write a constructor that creates and fills a 2D integer puzzle with random values from 1 through 9. Then write a method that searches for a valid pair in the same row or a later row, clears both elements, and reports whether a pair was found.

2D Arrays and Search22 minute target2D arraysconstructorsrandom valuesnested loopsmutation

Skills Tested

What this FRQ is really practicing

2D arraysconstructorsrandom valuesnested loopsmutation

Treat these skills as the study checklist. If any tag feels shaky, review that topic before attempting the full written response.

Starter Approach

How to begin without copying a solution

  1. 1Part A: create the puzzle 2D array using the requested row and column counts.
  2. 2Fill every cell with an equally likely random integer from 1 through 9.
  3. 3Part B: search row and later rows for another element that is equal to the selected value or sums with it to 10.
  4. 4If a valid pair is found, set both cells to 0 and return true; otherwise leave the puzzle unchanged and return false.

Write a first attempt before revealing any solution outline. Most AP CSA FRQ progress comes from tracing your own code and finding the missing case.

Common Mistakes

Mistakes to watch for while writing

Using Math.random() * 10, which can generate 0 or values outside the required 1 through 9 range after casting.
Searching from row 0 instead of starting at the given row.
Allowing the selected cell to match itself.
Clearing the selected cell before saving its original value.
Returning false too early from inside the nested loop.

Self Check

Review questions before you submit

Includes the SumOrSameGame constructor with row and column parameters.

The constructor should receive numRows and numCols.

Creates puzzle as a 2D int array with the requested dimensions.

Use new int[numRows][numCols].

Uses nested loops to visit rows and columns.

Every puzzle cell needs to be assigned.

Generates values from 1 through 9.

A common expression is (int)(Math.random() * 9) + 1.

Defines clearPair with the correct boolean return type.

The method should return true or false.

Stores or reuses the selected puzzle value.

Keep track of puzzle[row][col] before clearing anything.

Searches only the given row and later rows.

The outer loop should start at row, not 0.

Avoids pairing the selected cell with itself.

Check that the candidate row/column is not the original row/column.

Practice Links

Where to go next