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 Unique Wheel

Learn
Play
Prove
Problem context and objectives
Mission briefing

Puzzle systems engineer · A game mechanic is behaving incorrectly

Let only the first unused duplicate branch: The Unique Wheel.

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

How you win

  1. 1Recognize when Unique permutations matches the clues
  2. 2Keep this true after every move: each depth opens at most one branch for each distinct remaining value
  3. 3Reach the result within O(number of unique permutations times n)

Rules and pressure

  • Target cost: O(number of unique permutations times n)
  • State rule: each depth opens at most one branch for each distinct remaining value
Lesson 1 of 3

Live algorithm trace

Unique permutations

Complete execution
1 of 6
1
choice
1
2
0
1
2

At the root, the first 1 may branch before its duplicate.

1sort values
2if path complete: record
3scan candidate indices
4skip used indices
5skip duplicate when previous equal index is unused
6choose, recurse, and undo
sorted = [1,1,2]path = []
Truth to preserve / Cost target
Truth to preserve

each depth opens at most one branch for each distinct remaining value

Cost target

O(number of unique permutations times n)

Sorting groups duplicates. At one position, skip an equal value when its previous copy is still unused, because that previous copy would create the same branch first.

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