首页›Ken Shirriff›文章

Solving the NYTimes Pips puzzle with a constraint solver

Ken Shirriff · 2025年10月18日

AI 摘要 AI 生成,可能有误

The author describes using the MiniZinc constraint modeling system to solve the New York Times' new daily Pips puzzle, expressing the puzzle's domino-placement rules as constraints rather than procedural code and finding that solvers were easy to learn and typically produced solutions in milliseconds. However, they encountered complications such as the solver generating thousands of technically-valid but unwanted solutions, cryptic 'unsatisfiable' results when constraints contained mistakes, and unpredictable performance that varied widely depending on the solver backend (e.g., switching from Gecode to Chuffed). The article concludes with an explanation of how constraint solvers work internally, using search trees, backtracking, variable-ordering heuristics, and constraint propagation to prune the exponential search space.

The New York Times recently introduced a new daily puzzle called Pips. You place a set of dominoes on a grid, satisfying various conditions. For instance, in the puzzle below, the pips (dots) in the purple squares must sum to 8, there must be fewer than 5 pips in the red square, and the pips in the three green squares must be equal. (It doesn't take much thought to solve this "easy" puzzle, but the "medium" and "hard" puzzles are more challenging.)

The New York Times Pips puzzle from Oct 5, 2025 (easy). Hint: What value must go in the three green squares?

I was wondering about how to solve these puzzles with a computer. Recently, I saw an article on Hacker News—"Many hard LeetCode problems are easy constraint problems"—that described the benefits and flexibility of a system called a constraint solver. A constraint solver takes a set of constraints and finds solutions that satisfy the constraints: exactly what Pips requires.

继续阅读全文

为了尊重作者,这里只展示开头几段。你可以去原文阅读,或者在 HorizonReader 里读:划线做笔记、让 AI 帮忙。

更多来自 Ken Shirriff

Reverse engineering a vintage diode-transistor logic chip

AI 摘要While examining unidentified vintage ICs, the author reverse engineered a chip under a microscope and determined it was the Signetics ST680A from 1965, a quad NAND gate implemented with diode-transistor logic (DTL), part of the first IC family offered in a plastic DIP package. The article explains the chip's construction from bipolar transistors, diodes, and serpentine resistors, as well as how DTL NAND gates operate. Notably, the same silicon die was reused for at least three different chips (the 680A, 670A, and 616A) by applying different metal layers, a cost-saving technique Signetics used for both semi-custom and standard ICs.

Inside the Intel 8087 chip: floating-point addition and subtraction

AI 摘要This article examines the Intel 8087, a 1980 floating-point coprocessor that dramatically sped up arithmetic in the IBM PC, focusing on how its microcode and circuitry implement floating-point addition and subtraction. By decapping the chip and studying its die, the author explains key components such as the microcode ROM, the 80-bit datapath, the 69-bit integer adder, and the bit shifter. It also walks through the algorithm: aligning exponents by shifting significands, performing integer addition or subtraction, normalizing the result, and handling special cases like zero results, negative outcomes, infinities, and denormalized values.

Inside a 1980s filter chip that uses switched capacitors

AI 摘要The author analyzed a mysterious Harris IC labeled 'F1-10-5' and identified it as Harris's 1985 version of the MF10 switched-capacitor filter chip from National Semiconductor. The chip implements analog filters by rapidly switching 72 small polysilicon capacitors in and out of the circuit with CMOS switches, replacing resistors so that filter accuracy depends on stable capacitance ratios and a precise clock frequency rather than on-chip component values. Using a state variable filter design with three op-amps per filter, the chip provides high-pass, band-pass, and low-pass outputs while employing isolation rings, shield layers, and other techniques to suppress clock switching noise.

Reverse-engineering the vintage Intel 8087's tangent algorithm: more than CORDIC

AI 摘要The article describes how the author reverse-engineered Intel's vintage 8087 floating-point chip—by examining its die and microcode—to explain the algorithm behind its FPTAN tangent instruction. The 8087 combined the CORDIC algorithm (16 iterations using precomputed special angles) with a Padé approximant rational polynomial (3x/(3-x²)) applied to the tiny residual angle, achieving 64-bit accuracy while avoiding a costly division since the instruction returns separate numerator and denominator values. The three-phase process—pseudo-division to determine CORDIC decision bits, rational approximation of the remaining angle, and pseudo-multiplication to apply the rotations—let the chip compute a tangent in 90 microseconds versus 13,000 microseconds on the 8086.

Microcode in Intel's 8087 floating-point chip: the scale instruction

AI 摘要This article examines the microcode of Intel's 8087 floating-point coprocessor, focusing on the FSCALE instruction, which scales a floating-point number by a power of two much faster than a full multiplication. Although FSCALE seems trivial—just adding an integer to the number's exponent—the author, working with the Opcode Collective to reverse-engineer the chip's microcode, finds it uses over 140 micro-instructions and three levels of subroutine calls to handle special cases such as zeros, NaNs, denormals, and overflow/underflow. Along the way, the analysis illustrates key parts of the 8087's datapath, including the shifter, adder, and exponent converter, and reveals a hidden feature of the chip.