liveBook · Manning

What you will learn in Regular Expression Puzzles and AI Coding Assistants

24 puzzles solved by the author, with and without assistance from Copilot, ChatGPT and more

by David Mertz

Chapter by chapter

Chapter 1: The map and the territory

1.1 About regular expressions · 1.2 Rise of the programming machines · 1.3 Caveats · 1.4 Intentional software development · 1.5 As you read

What you learn in chapter 1 →

Chapter 2: Quantifiers and special sub-patterns

2.1 Puzzle 1 Wildcard scope · 2.2 Author thoughts What will each pattern match? · 2.3 AI thoughts CodingNet · 2.4 Puzzle 2 Words and sequences · 2.5 Author thoughts Think about what defines word boundaries · 2.6 AI thoughts The transformator · 2.7 Puzzle 3 Endpoint classes · 2.8 Author thoughts Refine the regular expression to match what we want · 2.9 AI thoughts Are friends electric? · 2.10 Puzzle 4 A configuration format · 2.11 Author thoughts Remember that shapes have edges · 2.12 AI thoughts Notes from the Cyberdyne vault · 2.13 Puzzle 5 The Human Genome · 2.14 Author thoughts Remember the central dogma of molecular biology · 2.15 AI thoughts Do androids dream of electric sheep?

What you learn in chapter 2 →

Chapter 3: Pitfalls and sand in the gears

3.1 Puzzle 6 Catastrophic backtracking · 3.2 Author thoughts Try hard to avoid catastrophes · 3.3 AI thoughts Technological singularity · 3.4 Puzzle 7 Playing dominoes · 3.5 Author thoughts Try to be more efficient than your first thought · 3.6 AI thoughts A war with sticks and stones · 3.7 Puzzle 8 Advanced dominoes · 3.8 Author thoughts Thoughts about digrams are always pleasant thoughts · 3.9 AI thoughts How many readers can pass the Turing Test? · 3.10 Puzzle 9 Sensor art · 3.11 Author thoughts Find a matching pattern, if possible · 3.12 AI thoughts My mind is going; I can feel it

What you learn in chapter 3 →

Chapter 4: Creating functions using regexen

4.1 Puzzle 10 Reimplementing str.count() · 4.2 Author thoughts How can a regex count the substring occurrences? · 4.3 AI thoughts Extraordinary machine · 4.4 Puzzle 11 Reimplementing str.count() (stricter) · 4.5 Author thoughts Write a Python function with the restrictions given · 4.6 AI thoughts The Horars of War · 4.7 Puzzle 12 Finding a name for a function · 4.8 Author thoughts Code is read far more often than it is written · 4.9 AI thoughts There are two hard problems in computer science · 4.10 Puzzle 13 Playing poker (Part 1) · 4.11 Author thoughts Functions are a big help in larger programs · 4.12 AI thoughts He can’t read my poker face · 4.13 Puzzle 14 Playing poker (Part 2) · 4.14 Author thoughts Large buildings are built from small bricks · 4.15 AI thoughts The society for preventing cruelty to humans · 4.16 Puzzle 15 Playing poker (Part 3) · 4.17 Author thoughts You better cheat, cheat, if you can’t win · 4.18 AI thoughts Someday machines will learn to count · 4.19 Puzzle 16 Playing poker (Part 4) · 4.20 Author thoughts You might risk identifying the “dead man’s hand” · 4.21 AI thoughts Free will is not free · 4.22 Puzzle 17 Playing poker (Part 5) · 4.23 Author thoughts Remember that three is more than two, but less than four · 4.24 AI thoughts Counting to two

What you learn in chapter 4 →

Chapter 5: Easy, difficult, and impossible tasks

5.1 Puzzle 18 Identifying equal counts · 5.2 Author thoughts Lateral thinking might help you find the answer · 5.3 AI thoughts Hic sunt dracones · 5.4 Puzzle 19 Matching before duplicate words · 5.5 Author thoughts Find a pattern that will fulfill the requirement · 5.6 AI thoughts Deep fakes in the Chomsky hierarchy · 5.7 Puzzle 20 Testing an IPv4 address · 5.8 Author thoughts Ask whether regexen are powerful enough for a problem · 5.9 AI thoughts I want to be a machine · 5.10 Puzzle 21 Matching a numeric sequence · 5.11 Author thoughts Rule out the impossible to be left with the solution · 5.12 AI thoughts Wheat and chessboards · 5.13 Puzzle 22 Matching the Fibonacci sequence · 5.14 Author thoughts The Golden Spiral beautifully generalizes Fibonacci numbers · 5.15 AI thoughts The fractal geometry of nature · 5.16 Puzzle 23 Matching the prime numbers · 5.17 Author thoughts Honor the fundamental theorem of arithmetic · 5.18 AI thoughts Sense and nonsense · 5.19 Puzzle 24 Matching relative prime numbers · 5.20 Author thoughts Nothing is either true or false but thinking makes it so · 5.21 AI thoughts Six impossible things before breakfast

What you learn in chapter 5 →

Chapter 6: Conclusions

What you learn in chapter 6 →

Concepts explained in this book

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.