News

johndcook.com
johndcook.com > blog > 03/20/2026 > embedded-regex-flags

Embedded regex flags

2+ hour, 50+ min ago  (214+ words) The hardest part of using regular expressions is not crafting regular expressions per se. In my opinion, the two hardest parts are minor syntax variations between implementations, and all the environmental stuff outside of regular expressions'per se. Embedded regular expression…...

johndcook.com
johndcook.com > blog > 12/19/2025 > regular-expressions-that-cross-lines

Regular expressions that cross lines

3+ mon, 1+ day ago  (383+ words) One of the fiddly parts of regular expressions is how to handle line breaks. Should regular expression searches be applied one line at a time, or should an entire file be treated as a single line? This morning I was…...

johndcook.com
johndcook.com > blog > 07/13/2025 > all-pieces-on-a-small-chessboard

All pieces on a small chessboard

8+ mon, 1+ week ago  (214+ words) Here's another little chess puzzle by Martin Gardner, taken from this paper. The task is to place all the pieces'king, queen, two bishops, two knights, and two rooks'on a 6 " 5 chessboard, with the requirement that the two bishops be on opposite…...

johndcook.com
johndcook.com > blog > 06/25/2025 > patching-functions-together

Patching functions together

8+ mon, 3+ week ago  (236+ words) The previous post looked at a function formed by patching together the function f(x) = log(1 +x) for negativex. The functions have a mediocre fit, which may be adequate for some applications, such as plotting data points, but not for others, such…...

johndcook.com
johndcook.com > blog > 05/28/2025 > clock-hands

How often to the hands of a clock line up?

9+ mon, 3+ week ago  (128+ words) How often do the hour and and minute hand of an analog clock point in the same direction? The hands start pointing the same direction at midnight, then the hour hand moves clockwise (!) by 360" in 12 hours. The minute hand moves…...

johndcook.com
johndcook.com > blog > 05/14/2025 > another-little-chess-puzzle

Another little chess puzzle

10+ mon, 5+ day ago  (129+ words) Here's another little chess puzzle by Martin Gardner, taken from the same paper as earlier. The task is to place two rooks, two bishops, and two knights on a 4 by 4 chessboard so that no piece attacks any other. As before,…...

johndcook.com
johndcook.com > blog > 05/13/2025 > a-crowded-little-chess-puzzle

A crowded little chess puzzle

10+ mon, 1+ week ago  (165+ words) Here's a puzzle by Martin Garnder [1]. Can a queen, king, rook, bishop, and knight be placed on a 4" board so no piece attacks another? There are two solutions, plus symmetries. Note that in all non-attacking chess puzzles, the colors of…...

johndcook.com
johndcook.com > blog > 05/10/2025 > non-attacking-bishops

The non-attacking bishops problem

10+ mon, 1+ week ago  (185+ words) How many bishops can you place on a chessboard so that no bishop is attacking any other bishop? For a standard 8 " 8 chessboard the answer is 14. In general, for an n " n chessboard the answer is 2n " 2. Here's one way to place…...

johndcook.com
johndcook.com > blog > 05/02/2025 > n-queens-in-3d

Non-attacking queens in an n by n by n cube

10+ mon, 2+ week ago  (458+ words) It's possible to place n queens on an n " n chess board so that no queen is attacking any other queen, provided n > 3. A queen is able to move any number of squares in any horizontal, vertical, or diagonal direction....

johndcook.com
johndcook.com > blog > 03/26/2025 > diagram-chase-2

Diagram chasing | visualizing five lemma as a game

11+ mon, 3+ week ago  (479+ words) The glass disk game is played on a grid. You have translucent colored glass disks you can either place on a vertex or an edge. There are two kinds of disks that can be placed on a vertex: red or…...