Skip to content
playdsa
Preferences

Make yourself comfortable.

Saved on this browser. Your device’s reduced-motion preference is always respected.

Theme
Advanced settings

The Word Board

Learn
Play
Prove
Problem context and objectives
Mission briefing

Puzzle systems engineer · A game mechanic is behaving incorrectly

Mark a cell only for the active path: The Word Board.

Brute force may pass the demo but fail when the world fills with players.

How you win

  1. 1Recognize when Word search backtracking matches the clues
  2. 2Keep this true after every move: the active path spells the matched word prefix and contains no repeated cell
  3. 3Reach the result within O(rows times cols times 4^wordLength)

Rules and pressure

  • Target cost: O(rows times cols times 4^wordLength)
  • State rule: the active path spells the matched word prefix and contains no repeated cell
Lesson 1 of 3

Live algorithm trace

Word search backtracking

Complete execution
1 of 5
A
cell
B
C
C
E
D

Choose the A cell as a candidate start.

1try each cell as start
2search(row,col,index)
3reject bounds, mismatch, or used cell
4if final character matched: succeed
5mark used and search four neighbors
6restore cell and return
word = ABCCEDstart = A
Truth to preserve / Cost target
Truth to preserve

the active path spells the matched word prefix and contains no repeated cell

Cost target

O(rows times cols times 4^wordLength)

Start from every matching cell. A recursive path advances four directions, temporarily marks its cell used, and restores it when the branch returns.

Your call · What should guide every step of this algorithm?

Help shape PlayDSA

Something confusing, broken, or missing? Leave a quick note without leaving your lesson.

Please leave out passwords, payment details and other private information.

Page included: /

Sign in to save feedback here, or send it with your email app. Your draft stays here while you sign in.

Open email instead