Created
February 15, 2013 15:19
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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