CTAN Comprehensive TeX Archive Network

Directory macros/context/contrib/context-sudoku

README.md

sudoku

Cont 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:

  1. \sudoku typesets a sudoku if valid.
  2. \startsudoku and \stopsudoku do the same as \sudoku, but text goes inside the environment.
  3. \sudokufile typesets a sudoku from a file if valid.
  4. \solvesudoku solves a sudoku if valid.
  5. \startsolvesudoku and \stopsolvesudoku do the same as \solvesudoku, but text goes inside the environment.
  6. \solvesudokufile solves a sudoku from a file if valid.
  7. \randomsudoku creates a random, unsolved sudoku.
  8. \sudokubuffer typesets a sudoku from a buffer.
  9. \solvesudokubuffer solves 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 Cont LMTX. I no longer use Cont 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 Cont

A port of Peter Norvig's sudoku solver to Lua/Cont. It provides four basic commands for typesetting sudokus, as well as a command handler.

Packagecontext-sudoku
Repositoryhttps://github.com/JairoAdelRio6/context-sudoku
Version 2026-02-14
LicensesMIT License
MaintainerJairo A. del Rio
Contained inTeX Live as context-sudoku
TopicsCont
Games
Sudoku
...
Guest Book Sitemap Contact Contact Author