# xkcd 1313: Regex Golf

DevFeed: [xkcd 1313: Regex Golf](<https://devfeed.tech/articles/xkcd-1313-regex-golf-40537.md>)

Original publisher: [Read original article](<http://nbviewer.ipython.org/url/norvig.com/ipython/xkcd1313.ipynb?create=1>)

Published: 2014-02-20T00:00:00Z

Content type: tutorial

Language: en

Sources: [Peter Norvig](<https://devfeed.tech/sources/peter-norvig.md>)

Topics: [Python](<https://devfeed.tech/topics/python.md>), [Regular expression](<https://devfeed.tech/topics/regular-expression.md>), [Algorithm](<https://devfeed.tech/topics/algorithm.md>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [algorithm](<https://devfeed.tech/tags/algorithm.md>), [code](<https://devfeed.tech/tags/code.md>), [implement](<https://devfeed.tech/tags/implement.md>), [program](<https://devfeed.tech/tags/program.md>), [python](<https://devfeed.tech/tags/python.md>), [regex](<https://devfeed.tech/tags/regex.md>), [strategy](<https://devfeed.tech/tags/strategy.md>), [xkcd](<https://devfeed.tech/tags/xkcd.md>)

## AI overview

Peter Norvig examines the regex-golf challenge from xkcd 1313 and develops a Python approach for finding a regular expression that matches presidential election winners while excluding losers. The article also investigates an apparent inconsistency in the original xkcd example.

## Source excerpt

Code to implement a meta-regex-golf program based on xkcd comic #1313. The code is "a program that plays regex golf with arbitrary lists..."