somdoku
TypeScript, React · live at somdoku.nl · mattijsf/somdoku
A daily Japanese sums puzzle for mobile. Everyone gets the same puzzle each day. The score is the time it took, shared as an emoji grid like Wordle. English and Dutch, picked from the browser language.
git clone https://github.com/mattijsf/somdoku.gitcd somdokunpm installnpm run dev
The site’s link preview image.
A 5×5 grid. Every row and column holds the digits 1 to 4 once and one black cell. The numbers along the edge are the sums of the groups of digits between the black cells, in order.
How a day’s puzzle is made
Section titled “How a day’s puzzle is made”Generate and test: build a random solution, derive the edge sums, and solve from the sums alone. A grid the solver can’t finish, or finishes in the wrong number of rounds, is dropped and the next attempt starts, up to 20,000 per seed.
- random solution
- edge sums
- solve from sums only
- keep or retry
Generate and test
Section titled “Generate and test”You can’t tell whether a grid makes a good puzzle by looking at it. It needs exactly one answer, and you should be able to reach that answer by working through the rows and columns without guessing. The only way to find out is to try solving it.
The game picks a random filled-in grid, works out the sums along the edges, and gives only those sums to a solver that reasons the way a person would. If the solver gets stuck, the grid goes in the bin and the game picks another one.
About one grid in six makes a fair puzzle. A day’s puzzle usually takes a dozen or so tries, well under a millisecond in the browser. The worst day I found in a year of dates needed 404 tries and 12 ms.
I could have done this ahead of time instead. There are only 161,280 possible grids, and solving all of them takes about three seconds. But then every visitor would download a list of 26,468 puzzles to save less than a millisecond.
Difficulty
Section titled “Difficulty”The solver also tells me how hard a puzzle is. It goes over the rows and columns in rounds, filling in what it can each time, and the number of rounds it needs is the difficulty. The date picks a level of 3, 4 or 5 rounds, and the game keeps drawing grids until one matches. The hard ones are rare: only 1,468 grids need five rounds or more.
Same puzzle everywhere
Section titled “Same puzzle everywhere”The date is hashed (FNV-1a) and used to seed a small random number generator (mulberry32). Every phone draws the same grids in the same order and lands on the same puzzle. No server is involved, and the game works offline. Changing the generator, or even the seed text, changes every day’s puzzle.
Sharing
Section titled “Sharing”When you share a result, you get your time and a block of green and yellow squares, one per cell, in the order you filled them in. Green means you never touched that cell again, yellow means you changed it later. The squares don’t show where the cells are.
No trackers or cookies. Older designs of this site.