librelist archives

« back to archive

a game

a game

From:
Allen Maxwell
Date:
2012-07-29 @ 21:27
saw this on twitter.  It's out of my leagues as I'm horrible with regex 
but it looked interesting.

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.