Skip to content

Instantly share code, notes, and snippets.

@rfunduk
Forked from avibryant/gist:3200554
Created July 30, 2012 13:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rfunduk/3206815 to your computer and use it in GitHub Desktop.
Save rfunduk/3206815 to your computer and use it in GitHub Desktop.
The Regex Game
The Regex Game
Avi Bryant
This is a game for two programmers, although it's easy to imagine variations for more.
It can be played over email, twitter, or IM, but it's easy to imagine a custom web app for it, and I encourage someone to build one.
Each player starts by thinking of a regular expression. The players should decide beforehand on dialect and length restrictions (eg, has to be JavaScript-compatible and under 20 characters).
They don't reveal the Regex, but if playing over email etc, should send each other a difficult to brute force hash (eg bcrypt) of the Regex for later verification.
They do reveal two strings: one which the Regex will match, and one which it will not.
The players then take turns trying to guess each others' Regex. When player 1 submits a guess to player 2, player 2 must respond in one of 3 ways:
- by agreeing that the guess is correct (defined as, matches the same set of strings as player 2's Regex)
- by providing a string that is matched by the guess but not by player 2’s Regex
- by providing a string that is matched by player 2's Regex but not by the guess
Whoever guesses the other player's Regex first (in the fewest number of tries) wins. If the two players come up with a correct guess in the same number of tries, whoever had a shorter Regex wins. If the regexen were the same length, it's a tie.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment