Directory macros/context/contrib/context-sudoku
sudoku
ConTeXt module to solve and display sudokus using the famous solver by Peter Norvig. The module has been reworked so that sudokus can be displayed directly in running text or within Metafun graphics as another library.
This module provides the following commands, as well as a command handler:
\sudokutypesets a sudoku if valid.\startsudokuand\stopsudokudo the same as\sudoku, but text goes inside the environment.\sudokufiletypesets a sudoku from a file if valid.\solvesudokusolves a sudoku if valid.\startsolvesudokuand\stopsolvesudokudo the same as\solvesudoku, but text goes inside the environment.\solvesudokufilesolves a sudoku from a file if valid.\randomsudokucreates a random, unsolved sudoku.\sudokubuffertypesets a sudoku from a buffer.\solvesudokubuffersolves a sudoku from a buffer if valid.
10. \setupsudoku is the command handler for commands above.
\setupsudoku understands the following parameters:
\setupsudoku [size=2em, evenbackground=, oddbackground=gray, frame=on, rulethickness=.5bp, n=42] % for random sudokus
\sudoku and \solvesudoku receive a text argument:
\solvesudoku[text=...]
\sudokufile and \solvesudokufile receive a file argument:
\sudokufile[file=...]
\sudokubuffer and \solvesudokubuffer receive a buffer argument:
\solvesudokubuffer[buffer=...]
Within Metafun, however, lmt_sudoku is generic and only understands a text parameter. There are three possible alternatives: display (to display a sudoku from a string without solving), solve (to solve a sudoku from a string), and random (to generate a random sudoku with N hints, ignoring any text argument).
lmt_sudoku [
alternative = "display",
text = "...",
size = 2EmWidth,
evenbackground = "",
oddbackground = "red",
frame = "one",
rulethickness = .5bp,
n = 42 % for random sudokus
]
Since lmt_sudoku draws directly a sudoku, you need to wrap it in an image if further manipulation is required.
See examples on t-sudoku.mklx
Caveat emptor: this module is only for ConTeXt LMTX. I no longer use ConTeXt MKIV, so no support is provided, sorry. Moreover, I'm using cutting-edge features, such as new macro extensions. An updated distribution is recommended.
Download the contents of this package in one zip archive (67.5k).
context-sudoku – Sudokus for ConTeXt
A port of Peter Norvig's sudoku solver to Lua/ConTeXt. It provides four basic commands for typesetting sudokus, as well as a command handler.
| Package | context-sudoku |
| Repository | https://github.com/JairoAdelRio6/context-sudoku |
| Version | 2026-02-14 |
| Licenses | MIT License |
| Maintainer | Jairo A. del Rio |
| Contained in | TeX Live as context-sudoku |
| Topics | ConTeXt Games Sudoku |