From bc4a2fa657968416f0accd9e8277b0b0ed1a3639 Mon Sep 17 00:00:00 2001 From: bangjiehan Date: Fri, 18 Apr 2025 15:43:28 +0800 Subject: [PATCH] Fix typo this formula should be 2^(n-1) --- .../15-regexp-catastrophic-backtracking/article.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/9-regular-expressions/15-regexp-catastrophic-backtracking/article.md b/9-regular-expressions/15-regexp-catastrophic-backtracking/article.md index c1d4040f76..9510971d6a 100644 --- a/9-regular-expressions/15-regexp-catastrophic-backtracking/article.md +++ b/9-regular-expressions/15-regexp-catastrophic-backtracking/article.md @@ -150,11 +150,11 @@ Here's what the regexp engine does: ...And so on. -There are many ways to split a sequence of digits `123456789` into numbers. To be precise, there are 2n-1, where `n` is the length of the sequence. +There are many ways to split a sequence of digits `123456789` into numbers. To be precise, there are 2n-1, where `n` is the length of the sequence. -- For `123456789` we have `n=9`, that gives 511 combinations. -- For a longer sequence with `n=20` there are about one million (1048575) combinations. -- For `n=30` - a thousand times more (1073741823 combinations). +- For `123456789` we have `n=9`, that gives 256 combinations. +- For a longer sequence with `n=21` there are about one million (1048576) combinations. +- For `n=31` - a thousand times more (1073741824 combinations). Trying each of them is exactly the reason why the search takes so long.