Skip to content

Instantly share code, notes, and snippets.

@rofr
Created February 15, 2013 15:19
Show Gist options
  • Save rofr/4961001 to your computer and use it in GitHub Desktop.
Save rofr/4961001 to your computer and use it in GitHub Desktop.
Here's one way to represent the hexagonal regex crossword puzzle, using Perl
# list of letters
my @letters = qw(a b c d e);
#each regex is associated with a list of indicies into the list of letters
my @puzzle =
(
['.*g.*v.*h.*' => [0..6]],
['[cr]*' => [7..14]],
['.*xexm*' => [15..23]],
['.*dd.*ccm.*' => [24..33]],
['.*xhcr.*x.*' => [34..44]],
['.*(.)(.)(.)(.)\4\3\2\1.*' => [45..56]],
['.*(in|se|hi)' => [57..69]],
#and so on
);
#untested
sub validate {
foreach my $tuple(@puzzle) {
my ($regex, $indices) = @$tuple;
die unless join '', @puzzle[@$indices] =~ /$regex/i;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment