summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/sudokubundle/printsudoku.sty
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2006-08-20 00:06:14 +0000
committerKarl Berry <karl@freefriends.org>2006-08-20 00:06:14 +0000
commit4cdec44e9893db7879eb9f2f34cfcbe52072abd0 (patch)
treece33773541a19ae10f609cc653168d9b36a758f1 /Master/texmf-dist/tex/latex/sudokubundle/printsudoku.sty
parent0a49b9e7033437699bdfc2b56ecafc0bae52cb5d (diff)
new (latex games) package sudokubundle 1.0 (17feb06)
git-svn-id: svn://tug.org/texlive/trunk@1992 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/sudokubundle/printsudoku.sty')
-rw-r--r--Master/texmf-dist/tex/latex/sudokubundle/printsudoku.sty151
1 files changed, 151 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/sudokubundle/printsudoku.sty b/Master/texmf-dist/tex/latex/sudokubundle/printsudoku.sty
new file mode 100644
index 00000000000..09dae133f6d
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/sudokubundle/printsudoku.sty
@@ -0,0 +1,151 @@
+%%
+%% This is file `printsudoku.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% sudokubundle.dtx (with options: `print')
+%%
+%% -----------------------------------------------------------------
+%% Author: Peter Wilson (herries dot press at earthlink dot net)
+%% Herries Press
+%% Copyright 2006 Peter R. Wilson
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either
+%% version 1.3 of this license or (at your option) any
+%% later version.
+%% The latest version of the license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3 or later is part of all distributions of
+%% LaTeX version 2003/06/01 or later.
+%%
+%% This work has the LPPL maintenance status "author-maintained".
+%%
+%% This work consists of the files listed in the README file.
+%% -----------------------------------------------------------------
+%%
+%%%% solvethem.tex Solve Sudoku files
+%%%% Peter Wilson
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{printsudoku}[2006/02/16 v1.0 typeset sudoku puzzles]
+
+\newread\s@dread
+\newwrite\s@dwrite
+
+%%%% open game file
+\newcommand*{\reads@dgame}[1]{%
+ \closein\s@dread
+ \openin\s@dread=#1}
+
+%%% set size of a game cell
+\newlength\halfs@dcell
+\newcommand*{\cellsize}[1]{%
+ \halfs@dcell=#1\relax
+ \halfs@dcell=0.5\halfs@dcell}
+\cellsize{2.5\baselineskip}
+%% set font for the numbers
+\newcommand*{\cluefont}[1]{\def\s@dfont{#1}}
+\cluefont{\Huge}
+
+%% counts for looping and cell positions
+\newcount\s@dncol
+\newcount\s@dnrow
+\newcount\s@dcolpos
+\newcount\s@drowpos
+
+%% insert the clues into the game array
+\newcommand*{\adds@dclues}{%
+ \firsts@dcluetrue
+ \s@dnrow\@ne
+ \loop
+ \ifnum\s@dnrow<10\relax
+ \read\s@dread to \s@dline
+ \firsts@dcluetrue
+ \s@drowpos=\s@dnrow
+ \multiply\s@drowpos\tw@
+ \advance\s@drowpos\m@ne
+ \s@dncol\@ne
+ \dos@dcols
+ \advance\s@dnrow\@ne
+ \repeat
+ \closein\s@dread}
+
+%% insert a row of clues
+\newcommand*{\dos@dcols}{%
+\bgroup
+ \loop
+ \ifnum\s@dncol<10\relax
+ \s@dcolpos=\s@dncol
+ \multiply\s@dcolpos\tw@
+ \advance\s@dcolpos\m@ne
+ \put(\s@dcolpos,-\s@drowpos){\makebox(0,0){\s@dfont\gets@dclue}}%
+ \advance\s@dncol\@ne
+ \repeat
+\egroup}
+
+%% get the next character in a string
+\def\gettwo#1#2\nowt{%
+ \gdef\istchar{#1}\gdef\restchars{#2}}
+\def\splitoff#1{\gettwo#1\nowt}
+%% a full stop (period)
+\gdef\s@dfstop{.}
+
+%% get the next clue in the line
+\newif\iffirsts@dclue
+\firsts@dcluetrue
+\newcommand*{\gets@dclue}{%
+ \iffirsts@dclue
+ \expandafter\splitoff\expandafter{\s@dline}%
+ \global\firsts@dcluefalse
+ \else
+ \expandafter\splitoff\expandafter{\restchars}%
+ \fi
+ \ifx\s@dfstop\istchar
+ \else
+ \istchar
+ \fi}
+
+%% typeset the grid, then add the clues
+\newcommand*{\s@dgame}{%
+ \setlength\unitlength\halfs@dcell
+ \begin{picture}(18,18)(0,-18)
+ \thinlines
+ \multiput(0,0)(2,0){10}{\line(0,-1){18}}
+ \multiput(0,0)(0,-2){10}{\line(1,0){18}}
+ \thicklines \linethickness{1pt}
+ \multiput(0,0)(6,0){4}{\line(0,-1){18}}
+ \multiput(0,0)(0,-6){4}{\line(1,0){18}}
+ \adds@dclues
+ \end{picture}}
+
+%% the whole shebang, where #1 is the name of the game file
+\newcommand*{\sudoku}[1]{%
+ \reads@dgame{#1}%
+ \s@dgame}
+
+\newcommand*{\puzzlefile}{puzz.sud}
+\newcommand*{\writepuzzle}[9]{%
+ \immediate\closeout\s@dwrite
+ \immediate\openout\s@dwrite=\puzzlefile
+ \immediate\write\s@dwrite{#1}%
+ \immediate\write\s@dwrite{#2}%
+ \immediate\write\s@dwrite{#3}%
+ \immediate\write\s@dwrite{#4}%
+ \immediate\write\s@dwrite{#5}%
+ \immediate\write\s@dwrite{#6}%
+ \immediate\write\s@dwrite{#7}%
+ \immediate\write\s@dwrite{#8}%
+ \immediate\write\s@dwrite{#9}%
+ \writes@dpuzzend}
+\newcommand*{\writes@dpuzzend}[1][\@empty]{
+ \ifx\@empty #1\else
+ \immediate\write\s@dwrite{ }%
+ \immediate\write\s@dwrite{#1}%
+ \fi
+ \immediate\closeout\s@dwrite}
+\newcommand*{\sudpuzznewline}{^^J}
+
+\endinput
+%%
+%% End of file `printsudoku.sty'.