grid
9
1
7
8
9
2
3
4
6
Brute force · count occurrences
▸1count ← {}2for each cell: count[value] ← count[value] + 13return the value counted twice, and the one counted zero times
state
- n3
- expect1..9
warming up the animation
An n×n grid should contain every integer from 1 to n² exactly once, but one value appears twice and another is missing. Return [repeated, missing].
▸1count ← {}2for each cell: count[value] ← count[value] + 13return the value counted twice, and the one counted zero times
line 1The grid should contain 1 to 9 exactly once each. Count what is actually there.