Category: Fun Stuff
Author/Contact Info Adam For writing the original table generating code.
wombat For form functionality.
Description: This is an improvement over Adam's crossword puzzle generator. Each cell now conatins a 1 character text field, allowing you to actually fill it in and submit your answers to a site. The processing script is straightforward and one can program any number of events to happen when someone solves a puzzle (or submits an incorrect answer) :-). The one in the example is the same puzzle that was written by KM here. Since he said that he would post the answers in a few days, I shall refrain from including the solution in the code.

Basically, in order to find the correct solution string to plug into the solution checker, you need to run each block's character together into one long string. It's ugly from a human standpoint, but it's easy to process. I hope to create a dynamic generator in the near future which would, from a list of words and corresponding clues automatically generate the grid, and thereby easily generate the solution string. Enjoy! ~W
The grid generator code:
#!/usr/bin/perl -w

use strict;
# I wrote this to generate a file, not be a cgi script, but you could.
# use;

open GRID, '>../html/grid.html' or die $!;
select GRID;

print "<HTML><BODY>\n";
print "<FORM method=GET action=>

my $cellwidth = '20';  # pixel or percent
my $cellheight = '4'; # pixels only
my $counter = 0;

sub Solid
    return "<TD WIDTH='$cellwidth' HEIGHT='$cellheight' ".

sub Open
    return "<TD WIDTH='$cellwidth' HEIGHT='$cellheight' ".
           "BGCOLOR='WHITE' VALIGN='BOTTOM'><input type=text size=1 na
+me='x' max

sub Numbered
    return "<TD WIDTH='$cellwidth' HEIGHT='$cellheight' BGCOLOR='WHITE
           "ALIGN='LEFT' VALIGN='TOP'><FONT SIZE=-2>$counter</FONT><in
+put type=t
ext size=1 name='x' maxlength=1></TD>\n";

# These two arrays are used to generate the grid.
# numbers in @line correspond to the functions in @type.
# 0 black box, 1, white box, 2, numbered box.
my @type = ( \&Solid, \&Open, \&Numbered );
my @line = (

print "<TABLE BORDER=1 SHADE=0>\n";
foreach ( @line )
    print "<TR>\n";
    print map { &{$type[$_]} } split //;
    print "</TR>";
print "\n</TABLE>";
print "<input type=submit value=\"I'd like to solve the puzzle please\
print "\n</form>";
print "</body></html>";

And the processing code:

#! /usr/bin/perl -w
require ("");


print "Content-type: text/html\n\n";

@my_query = split(/&/,$ENV{'QUERY_STRING'});

foreach (@my_query)
@key_value = split(/=/,$_);
push @solved, $key_value[1];

$solved_str = join('',@solved);

if ($solved_str eq "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwx

if ($success)
print << 'End_Of_Text';
<body bgcolor=#004400 text=ffffff>
<h3>Hooray!  You've solved the puzzle!</h3>
Congrats.  Go out, have a beer. Eat some salami.  
print << 'End_Of_Text';
<body bgcolor=#440000 text=ffffff>
<h3>Sorry, try again.</h3>
One of your answers is incorrect.  Click back and try again.