cs-040 — The Anagram Detector

FieldValue
idcs-040
difficultyAdvanced
topicsstrings, normalisation
lecturelecture-10
estimated time5-minute attempt + 10-minute discussion
prerequisitesthe full Block I-III toolbox and proof-shaped reasoning
objectivemake and justify design decisions where the method itself is the challenge
solutionheld by the instructor; discussed after the attempt

Problem

Decide if two phrases are anagrams ignoring case, spaces, and punctuation. Normalisation as the key idea; two implementation routes (sort vs count).

Your deliverable is the verdict for the worked instance, the normalisation rules you applied, and one input that exposes a missing rule. If the problem is ambiguous anywhere, state the assumption you are making and carry on — a stated assumption is part of a good answer.

Examples

Solve for the worked instance first. Then ask what would change if one number, name, or condition were replaced by something stranger.

What to notice

Discussion starter

After the solution is revealed, the class spends five minutes on this prompt: "Which normalisation steps are safe to merge, and which change the answer if done in the wrong order?"

Constraints and assumptions

Hints and extension