# If the solution to the problem is a regex, then you have two problems

**URL:** <https://boards.straightdope.com/t/if-the-solution-to-the-problem-is-a-regex-then-you-have-two-problems/741278>\
**Category:** Miscellaneous and Personal Stuff I Must Share\
**Created:** [December 24, 2015, 5:46pm UTC](https://boards.straightdope.com/t/if-the-solution-to-the-problem-is-a-regex-then-you-have-two-problems/741278 "2015-12-24T17:46:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![UncleRojelio](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/unclerojelio/32/3160_2.png) [@UncleRojelio](https://boards.straightdope.com/u/UncleRojelio)\
**Post date:** [December 24, 2015, 5:46pm UTC](https://boards.straightdope.com/t/if-the-solution-to-the-problem-is-a-regex-then-you-have-two-problems/741278/1 "2015-12-24T17:46:33Z")

</div>

Finally, [my kind of crossword puzzle](https://s3-us-west-1.amazonaws.com/gregable/puzzle.html). The kind for computer nerds, geeks and coders. Skip this thread if you don’t know what is a regular expression.

---

<div class="post-metadata">

**Author:** ![LSLGuy](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/lslguy/32/5813_2.png) [@LSLGuy](https://boards.straightdope.com/u/LSLGuy)\
**Post date:** [December 25, 2015, 5:31pm UTC](https://boards.straightdope.com/t/if-the-solution-to-the-problem-is-a-regex-then-you-have-two-problems/741278/2 "2015-12-25T17:31:28Z")

</div>

Now I have 40 problems: 39 regexps plus all the stuff I’m now not going to get done this week! Thanks a heap there **UncleR**! 😃

Reminds me first of this: [xkcd: Nerd Sniping](http://xkcd.com/356/). With a side order of [xkcd: Regex Golf](http://xkcd.com/1313/)

---

<div class="post-metadata">

**Author:** ![cmkeller](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/cmkeller/32/118_2.png) [@cmkeller](https://boards.straightdope.com/u/cmkeller)\
**Post date:** [December 25, 2015, 5:34pm UTC](https://boards.straightdope.com/t/if-the-solution-to-the-problem-is-a-regex-then-you-have-two-problems/741278/3 "2015-12-25T17:34:00Z")

</div>

But at least a bitch isn’t one of them!

---

<div class="post-metadata">

**Author:** ![aktep](https://avatars.discourse-cdn.com/v4/letter/a/f0a364/32.png) [@aktep](https://boards.straightdope.com/u/aktep)\
**Post date:** [December 25, 2015, 5:35pm UTC](https://boards.straightdope.com/t/if-the-solution-to-the-problem-is-a-regex-then-you-have-two-problems/741278/4 "2015-12-25T17:35:17Z")

</div>

I did it! That was … interesting.

---

<div class="post-metadata">

**Author:** ![UncleRojelio](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/unclerojelio/32/3160_2.png) [@UncleRojelio](https://boards.straightdope.com/u/UncleRojelio)\
**Post date:** [December 25, 2015, 7:25pm UTC](https://boards.straightdope.com/t/if-the-solution-to-the-problem-is-a-regex-then-you-have-two-problems/741278/5 "2015-12-25T19:25:11Z")

</div>

> [@LSLGuy](#):
>
> Now I have 40 problems: 39 regexps plus all the stuff I’m now not going to get done this week! Thanks a heap there **UncleR**! 😃
> 
> Reminds me first of this: [xkcd: Nerd Sniping](http://xkcd.com/356/). With a side order of [xkcd: Regex Golf](http://xkcd.com/1313/)

My pleasure. I’ll admit, I’m only about 75% done. The consequences for slacking off to do puzzles are quite steep around here for the next few days.

I did see on the inter webs where someone wrote a Haskell program to solve this puzzle. To me, that is even more intriguing than the puzzle itself.

---

<div class="post-metadata">

**Author:** ![LSLGuy](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/lslguy/32/5813_2.png) [@LSLGuy](https://boards.straightdope.com/u/LSLGuy)\
**Post date:** [December 26, 2015, 12:04am UTC](https://boards.straightdope.com/t/if-the-solution-to-the-problem-is-a-regex-then-you-have-two-problems/741278/6 "2015-12-26T00:04:32Z")

</div>

> [@UncleRojelio](#):
>
> My pleasure. I’ll admit, I’m only about 75% done. The consequences for slacking off to do puzzles are quite steep around here for the next few days.
> 
> I did see on the inter webs where someone wrote a Haskell program to solve this puzzle. To me, that is even more intriguing than the puzzle itself.

You can view a regex as a string generator just as readily as a string recognizer.

Armed with a function to take a regex and return a collection of all matching strings of length _n_, the rest of the problem is just one of searching the 39 collections to find strings with matching values in matching spots per the puzzle geometry. For which task you \*might \*be able to use a regex :eek: 🙂
