Is there a PostScript program that prints a crossword puzzle diagram, with automatic numbering, from a...
references/software/crossword.printing New
New entry, edited from material collected for the archive and not yet in a released version.
Problem
Is there a PostScript program that prints a crossword puzzle diagram, with automatic numbering, from a plain-text picture of the grid? [ Editor: problem statement reconstructed from a posting to comp.lang.postscript and rec.puzzles, September 1996. ]
Show solution
[ Editor: the program's comments are partly in Dutch ("vakje" = box,
"breed" = width, "hoog" = height; "lange ij" is the Dutch letter ij,
typed as Y). The grid at the end is the Volkskrant cryptogram of
31 August 1996, as given in the posting. ]
I've just written a postscript program to print crossword puzzles:
--cut here--
%!PS-Adobe 3.0
% Print a crossword puzzle diagram
% features of this version:
% automatic numbering
% for Dutch language: lange ij (invoeren als Y)
% automatic detection of height and width
% letters centrered in the boxes
% copyright this program 1996 C. van den Ouweland
% copyright this puzzle 1996 Volkskrant/Jan Meulendijks
% INSTRUCTIONS
% modify contents at the very end of this file.
% all lines should be equally long (max 29 characters)
% use slash (/) for a black box
% use space ( ) for a white box
% after last line, put a line with just a single percent sign (%)
% modify title of the crossword here:
(Cryptogram 31 augustus 1996)
/Times-Roman findfont 0.8 scalefont setfont
/vakje 30 def
0.025 setlinewidth
%0.3 0.4 0.1 sethsbcolor
40 700 translate
vakje dup scale
% modify title below:
0.1 1.5 moveto show
{
gsave
/hoog 0 def
/buf0 30 string def
/buf1 30 string def
/buf2 30 string def
/eof false def
/coubuf 3 string def
/count 0 def
/breed currentfile buf2 readline pop length def
buf1 dup
0 1 breed {47 put dup} for
pop pop
{ /hoog hoog 1 add def
0 %index
/buf0 buf1
/buf1 buf2 dup breed 47 put def
/buf2 buf0 def def
currentfile buf2 readline pop
(%) eq
{
buf2 dup
0 1 breed {47 put dup} for
pop pop
/eof true def
} if
/vorig true def
buf0
{ % index T
exch % T index
dup breed ge {exit}if
dup 0 moveto % T index
dup buf1 exch get % T index C
dup 47 eq % T index C {C="/"?}
{ % T index "/"
pop % T index
exch pop % index
1 0 rlineto
0 1 rlineto
-1 0 rlineto
closepath fill %index
/vorig true def
}
{ % T index C
dup 89 eq % T index C {C="Y"?}
{ pop (ij) } % Change it to "ij"
{
(?) dup 0 % T index C (?) (?) 0
4 -1 roll % T index (?) (?) 0 C
put % T index (C)
} ifelse
gsave
dup stringwidth pop
1 sub -2 div 0.3 rmoveto
show grestore % T index
exch % index T
% bepaal of hier een verticaal woord begint
% is het blokje hierboven zwart?
47 eq % index bool
{ % index
%kijk naar het blokje hieronder
dup buf2 exch get % index B
% is het blokje hieronder zwart?
47 ne
}
{ false }
ifelse % index bool
% als er geen verticaal woord begint, bepaal dan
% of er een horizontaal woord begint
{ true }
{ %kijk naar het blokje links
vorig
{ %kijk naar het blokje rechts
dup buf1 exch 1 add get 47 ne
}
{ false }
ifelse
}
ifelse
{ gsave
0.08 0.75 rmoveto
0.4 dup scale
/count count 1 add dup coubuf cvs show def
grestore
} if
% index
/vorig false def
} ifelse
1 add %index
} forall
grestore
0 -1 translate
gsave
eof {exit} if
} loop
grestore
0 1 moveto breed hoog 1 add
{dup 0 rlineto dup neg 1 rmoveto}repeat
pop stroke
0 1 moveto hoog breed 1 add
{dup 0 exch rlineto dup neg 1 exch rmoveto}repeat
pop stroke
showpage
} exec
/hogeschool////
/u/y//h/v/e////
mismanagement/l
/s/n//r/r/f/ode
/zwartleren/t/e
/o/s//e/e/e/a/r
e t s/ditmaal
/k/i//t/e///l/i
file/ o n a i n
/n/k//n///a/n/g
/g/m/a//b/n/d/v
/sleur/papkerel
/b/e/m//h/o/u/i
e s e r m/koe
/v/t/l//e/e/k/g
/e/e/Y/kien/e/e
/lariks/n//snor
%
--cut here--
-- Charles van den Ouweland <ouweland@ats.nld.alcatel.nl>