Arthur Whitney's one liner sudoku solver (2011)
Arthur Whitney’s famously terse one-line Sudoku solver in the K programming language is used as a springboard to examine the appeal and tradeoffs of array-oriented, symbol-heavy languages like K and APL. Commenters contrast the elegance and density of such solutions with more verbose, readable implementations in languages like Python or Prolog, debating maintainability, learning curves, and how these notations change the way programmers think about problems. Along the way, they touch on Sudoku as both a meditative puzzle and a playground for algorithm design, and question simple metrics like lines of code as measures of code quality.
Sudoku: Meditation vs Automation
- Some treat sudoku as a calm, guaranteed-win pastime; optimizing solvers feels contrary to that.
- Others find the optimization itself meditative: exploring algorithms, heuristics, and simulation.
- Solvers are valued to verify puzzle solvability, especially for non-commercial sources where errors are more common (there’s disagreement whether commercial or hobbyist sources are worse).
- In teaching (e.g., C++ courses) sudoku is praised as a self‑contained, OS‑agnostic project that exercises data structures and algorithms.
Whitney’s K One‑Liner & Algorithm
- The K solver is identified as breadth‑first search over puzzle states, not heuristic backtracking.
- It iterates over zero cells and systematically branches possible fillings.
- Some compare it to short Python/Numpy implementations, noting that high-level array operations can keep other languages concise, though typically not as terse as K.
Array Languages: Power, Style, and Cognition
- Advocates claim array languages (K, APL, J, BQN, Uiua, Q) enable compact, expressive reasoning over arrays and can feel like a “superpower” for interactive data work.
- Critics describe the glyph-heavy syntax as “line noise,” hard to remember, and hostile to newcomers; others counter that the core is small and learnable.
- Debate over whether languages like Julia + Numpy can match array languages semantically, with disagreement about primitives, tables, IPC, and ergonomics.
- Discussion of first‑class functions and higher‑rank arrays in newer array languages; some see this as a major semantic advance.
Readability, Maintainability, and Metrics
- Many stress that one-liner golf is a fun stunt, not production style. Real code often uses multiple lines, comments, and more imperative structure.
- Maintainability concerns: dense expressions are powerful but can be “all or nothing” unless you know the idioms; some report hitting a learning “wall.”
- Others argue that once fluent, reading dense array code is no harder than reading many lines of traditional code.
- LoC is widely seen as a bad complexity metric; alternatives like AST node counts or information content (bits) are discussed, but none are viewed as fully satisfactory.
Why People Play or Solve Sudoku
- Motivations include mental exercise, quick distraction (e.g., on planes), family activity, and the satisfaction of small, repeated wins.
- Variant sudokus with additional constraints are praised for elegant logical paths, though some find them overly convoluted.
- Writing solvers is framed as a separate, enjoyable puzzle that teaches general techniques (constraint solving, search, backtracking).