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 Anagram Archive

Learn
Play
Prove
Problem context and objectives
Mission briefing

Puzzle systems engineer · A game mechanic is behaving incorrectly

File words by a canonical signature: The Anagram Archive.

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

How you win

  1. 1Recognize when Canonical-key hashing matches the clues
  2. 2Keep this true after every move: every word in one bucket has exactly the same character multiset
  3. 3Reach the result within O(n k log k)

Rules and pressure

  • Target cost: O(n k log k)
  • State rule: every word in one bucket has exactly the same character multiset
Lesson 1 of 3

Live algorithm trace

Canonical-key hashing

Complete execution
1 of 7

Create an insertion-ordered map for canonical signatures.

1groups = ordered map
2for word in words
3key = sorted characters
4append word to groups[key]
5return groups in key discovery order
groups = {}
Truth to preserve / Cost target
Truth to preserve

every word in one bucket has exactly the same character multiset

Cost target

O(n k log k)

Anagrams become identical after the same canonical transformation. Use a sorted-character signature as a hash key, append each word to its matching group, then return groups in first-signature order.

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