AP CSA FRQ Guide
2009 FRQ 4: TileGame
Find where a numbered tile fits in a row of tiles by matching touching edges, then try its possible orientations and insert it at most once.
ArrayList Insertion and Object Rotation22 minute targetArrayListobjectsinsertionrotationhelper methods
Skills Tested
What this FRQ is really practicing
ArrayListobjectsinsertionrotationhelper methods
Review these topics before attempting the problem.
Starter Approach
How to begin with your own plan
- 1Part A: return 0 for an empty board; otherwise test the front, every gap between tiles, and the end in the current orientation.
- 2Match both adjoining edges when inserting between two existing tiles; return -1 if no position fits.
- 3Part B: use getIndexForFit and rotate the new tile to check up to four orientations, inserting it once when a fit is found.
- 4Preserve the relative order and orientations of the existing tiles; return false if no orientation fits.
Attempt the problem before opening the solution.
Common Mistakes
Mistakes to watch for while writing
Checking only interior positions and missing the empty board or either end.
Matching just one of the two edges for an interior insertion.
Adding the same tile more than once or rotating an existing board tile.
Self Check
Review questions before you submit
Compares left and right tile edges.
Interior insertions must match both neighboring tiles.
Provides a -1 result when the orientation does not fit.
Check both ends and all interior positions before reporting failure.
Uses rotate to try other orientations of the new tile.
A square tile has four possible orientations.
Uses the fit helper and inserts at the returned position.
Insert into board with add(index, tile), then finish successfully.
Practice Links
