| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% sudokubundle.dtx |
| 4 |
% |
| 5 |
% Author: Peter Wilson (Herries Press) herries dot press at earthlink dot net |
| 6 |
% Copyright 2006 Peter R. Wilson |
| 7 |
% |
| 8 |
% This work may be distributed and/or modified under the |
| 9 |
% conditions of the LaTeX Project Public License, either |
| 10 |
% version 1.3 of this license or (at your option) any |
| 11 |
% later version. |
| 12 |
% The latest version of the license is in |
| 13 |
% http://www.latex-project.org/lppl.txt |
| 14 |
% and version 1.3 or later is part of all distributions of |
| 15 |
% LaTeX version 2003/06/01 or later. |
| 16 |
% |
| 17 |
% This work has the LPPL maintenance status "author-maintained". |
| 18 |
% |
| 19 |
% This work consists of the files listed in the README file. |
| 20 |
% |
| 21 |
%<*driver> |
| 22 |
\documentclass[twoside]{ltxdoc} |
| 23 |
\usepackage{printsudoku} |
| 24 |
\usepackage{url} |
| 25 |
\usepackage[draft=false, |
| 26 |
plainpages=false, |
| 27 |
pdfpagelabels, |
| 28 |
bookmarksnumbered, |
| 29 |
hyperindex=false |
| 30 |
]{hyperref} |
| 31 |
\makeatletter |
| 32 |
\@mparswitchfalse |
| 33 |
\makeatother |
| 34 |
\EnableCrossrefs |
| 35 |
\CodelineIndex |
| 36 |
%%% \RecordChanges |
| 37 |
%%%%%%%%%%%%% uncomment the next line to show all the code details |
| 38 |
%%\OnlyDescription |
| 39 |
%%% Don't use the default Short Verb. |
| 40 |
\AtBeginDocument{\DeleteShortVerb{\|}} |
| 41 |
%%% page headings to aid navigation, but I don't like Uppercased titles. |
| 42 |
\renewcommand{\MakeUppercase}[1]{#1} |
| 43 |
\pagestyle{headings} |
| 44 |
\setcounter{StandardModuleDepth}{1} |
| 45 |
\begin{document} |
| 46 |
\DocInput{sudokubundle.dtx} |
| 47 |
\end{document} |
| 48 |
%</driver> |
| 49 |
% |
| 50 |
% \fi |
| 51 |
% |
| 52 |
% \CheckSum{5494} |
| 53 |
% |
| 54 |
% \DoNotIndex{\',\.,\@M,\@@input,\@addtoreset,\@arabic,\@badmath} |
| 55 |
% \DoNotIndex{\@centercr,\@cite} |
| 56 |
% \DoNotIndex{\@dotsep,\@empty,\@gobble,\@gobbletwo,\@ignoretrue} |
| 57 |
% \DoNotIndex{\@input,\@ixpt,\@m} |
| 58 |
% \DoNotIndex{\@minus,\@ne,\@nil,\@nomath,\@plus,\@set@topoint} |
| 59 |
% \DoNotIndex{\@tempboxa,\@tempcnta,\@tempdima,\@tempdimb} |
| 60 |
% \DoNotIndex{\@tempswafalse,\@tempswatrue,\@viipt,\@viiipt,\@vipt} |
| 61 |
% \DoNotIndex{\@vpt,\@warning,\@xiipt,\@xipt,\@xivpt,\@xpt,\@xviipt} |
| 62 |
% \DoNotIndex{\@xxpt,\@xxvpt,\\,\ ,\addpenalty,\addtolength,\addvspace} |
| 63 |
% \DoNotIndex{\advance,\Alph,\alph} |
| 64 |
% \DoNotIndex{\arabic,\ast,\begin,\begingroup,\bfseries,\bgroup,\box} |
| 65 |
% \DoNotIndex{\bullet} |
| 66 |
% \DoNotIndex{\cdot,\cite,\CodelineIndex,\cr,\day,\DeclareOption} |
| 67 |
% \DoNotIndex{\def,\DisableCrossrefs,\divide,\DocInput,\documentclass} |
| 68 |
% \DoNotIndex{\DoNotIndex,\egroup,\ifdim,\else,\fi,\em,\endtrivlist} |
| 69 |
% \DoNotIndex{\EnableCrossrefs,\end,\endgroup} |
| 70 |
% \DoNotIndex{\endlist,\everycr,\everypar,\ExecuteOptions,\expandafter} |
| 71 |
% \DoNotIndex{\fbox} |
| 72 |
% \DoNotIndex{\filedate,\filename,\fileversion,\fontsize,\framebox,\gdef} |
| 73 |
% \DoNotIndex{\global,\halign,\hbox,\hfil,\hfill,\hrule} |
| 74 |
% \DoNotIndex{\hsize,\hskip,\hspace,\hss,\if@tempswa,\ifcase,\or,\fi,\fi} |
| 75 |
% \DoNotIndex{\ifhmode,\ifvmode,\ifnum,\iftrue,\ifx,\fi,\fi,\fi,\fi,\fi} |
| 76 |
% \DoNotIndex{\input} |
| 77 |
% \DoNotIndex{\jobname,\kern,\leavevmode,\let} |
| 78 |
% \DoNotIndex{\list,\llap,\long,\m@ne,\m@th} |
| 79 |
% \DoNotIndex{\month,\newcommand,\newcounter,\newenvironment} |
| 80 |
% \DoNotIndex{\NeedsTeXFormat,\newdimen} |
| 81 |
% \DoNotIndex{\newlength,\newpage,\nobreak,\noindent,\null,\number} |
| 82 |
% \DoNotIndex{\numberline,\OldMakeindex,\OnlyDescription,\p@} |
| 83 |
% \DoNotIndex{\par,\paragraph,\paragraphmark,\parfillskip} |
| 84 |
% \DoNotIndex{\penalty,\PrintChanges,\PrintIndex,\ProcessOptions} |
| 85 |
% \DoNotIndex{\protect,\ProvidesClass} |
| 86 |
% \DoNotIndex{\refstepcounter,\relax,\renewcommand,\reset@font} |
| 87 |
% \DoNotIndex{\rightskip,\rlap,\rmfamily,\roman} |
| 88 |
% \DoNotIndex{\roman,\secdef,\selectfont,\setbox,\setcounter,\setlength} |
| 89 |
% \DoNotIndex{\settowidth,\sfcode,\skip,\sloppy,\slshape,\space} |
| 90 |
% \DoNotIndex{\symbol,\the,\trivlist,\typeout,\tw@,\undefined,\uppercase} |
| 91 |
% \DoNotIndex{\usecounter,\usefont,\usepackage,\vfil,\vfill,\viiipt} |
| 92 |
% \DoNotIndex{\viipt,\vipt,\vskip,\vspace} |
| 93 |
% \DoNotIndex{\wd,\xiipt,\year,\z@} |
| 94 |
% \DoNotIndex{\@namedef,\@nameuse,\csname,\endcsname} |
| 95 |
% |
| 96 |
% \def\dtxfile{sudokubundle.dtx} |
| 97 |
% \def\fileversion{1.0a} \def\filedate{2006/02/19} |
| 98 |
% |
| 99 |
% \newcommand*{\fref}[1]{Figure~\ref{#1}} |
| 100 |
% \newcommand*{\tref}[1]{Table~\ref{#1}} |
| 101 |
% \newcommand*{\Lopt}[1]{\textsf {#1}} ^^A typeset an option |
| 102 |
% \newcommand*{\file}[1]{\texttt {#1}} ^^A typeset a file |
| 103 |
% \newcommand*{\Lcount}[1]{\textsl {\small#1}} ^^A typeset a counter |
| 104 |
% \newcommand*{\pstyle}[1]{\textsl {#1}} ^^A typeset a pagestyle |
| 105 |
% \newcommand*{\Lenv}[1]{\texttt {#1}} ^^A typeset an environment |
| 106 |
% \newcommand*{\Lpack}[1]{\textsf {#1}} ^^A typeset a package |
| 107 |
% \newcommand*{\ctt}{\textsc{ctt}} |
| 108 |
% \newcommand{\Lclass}[1]{\textsf{#1}} |
| 109 |
% \newcommand{\PWcomment}[1]{} |
| 110 |
% \newenvironment{PW}{\itshape}{} |
| 111 |
% \renewenvironment{PW}{\sffamily}{} |
| 112 |
% \newcommand{\texbook}{\textit{TeXbook}} |
| 113 |
% \newcommand{\thetexbook}{\textit{The TeXbook}} |
| 114 |
% \newcommand{\egstart}{} |
| 115 |
% \newcommand{\egmid}{} |
| 116 |
% \newcommand{\egend}{} |
| 117 |
% \renewcommand{\egstart}{ |
| 118 |
% \par |
| 119 |
% \begingroup |
| 120 |
% \centering |
| 121 |
% \begin{minipage}{0.45\textwidth}} |
| 122 |
% \renewcommand{\egmid}{ |
| 123 |
% \end{minipage}\hfill\begin{minipage}{0.45\textwidth}} |
| 124 |
% \renewcommand{\egend}{ |
| 125 |
% \end{minipage}\par\endgroup} |
| 126 |
% |
| 127 |
% \title{The sudoku bundle for displaying, solving and generating Sudoku |
| 128 |
% puzzles\thanks{This file (\dtxfile) |
| 129 |
% has version number \fileversion, last revised on \filedate.}} |
| 130 |
% \author{Peter |
| 131 |
% Wilson\thanks{\texttt{herries dot press at earthlink dot net}}\\ |
| 132 |
% The Herries Press} |
| 133 |
% \date{\filedate} |
| 134 |
% \maketitle |
| 135 |
% |
| 136 |
% \begin{abstract} |
| 137 |
% The \Lpack{sudoku bundle} provides a coordinated set of packages for |
| 138 |
% displaying, solving, and generating Sudoku puzzles. A set of over 50 puzzles |
| 139 |
% is also supplied. |
| 140 |
% \end{abstract} |
| 141 |
% |
| 142 |
% \tableofcontents |
| 143 |
% \listoffigures |
| 144 |
% |
| 145 |
% \section{Introduction} |
| 146 |
% |
| 147 |
% In December 2005 the \emph{PracTeX Journal}~\cite{PRACTEX} set a competition |
| 148 |
% about Sudoku puzzles. |
| 149 |
% Depending on their experience with \TeX\ contestants were asked to |
| 150 |
% (a) typeset a particular puzzle, (b) typeset |
| 151 |
% a puzzle described in a `sudoku' file, (c) create a solver for |
| 152 |
% sudoku puzzles. I entered the competition with a printer and solver. |
| 153 |
% Following from this it was no great effort to develop a matching |
| 154 |
% Soduko puzzle generator. |
| 155 |
% |
| 156 |
% The packages described here have been developed completely independently |
| 157 |
% from Paul Abraham's \Lpack{sudoku} package~\cite{SUDOKU}, which I did |
| 158 |
% not see until after I had finished work on them. |
| 159 |
% |
| 160 |
% A Sudoku puzzle consists a 9 by 9 grid of cells with |
| 161 |
% some of the cells containing a number between 1 and 9, such as is |
| 162 |
% shown in \fref{fig:puz1}. The problem |
| 163 |
% is to place a number between 1 and 9 in each cell such that no number appears |
| 164 |
% more than once in each row and in each column and in each minor 3 by 3 grid. |
| 165 |
% The solution to the example puzzle is shown in \fref{fig:ans1}. The |
| 166 |
% puzzle and answer have been typeset using the \Lpack{printsudoku} package. |
| 167 |
% |
| 168 |
% \changes{v1.0a}{2006/02/19}{Deleted clue from example puzzle, |
| 169 |
% courtesy William Hammond} |
| 170 |
% \renewcommand*{\puzzlefile}{examout.sud} |
| 171 |
% \writepuzzle% |
| 172 |
% {..483..72}% |
| 173 |
% {.12....8.}% |
| 174 |
% {..52.13..}% |
| 175 |
% {....62.91}% |
| 176 |
% {7..5.9..3}% |
| 177 |
% {94.78....}% |
| 178 |
% {..39.74..}% |
| 179 |
% {.5....61.}% |
| 180 |
% {.8..469..}% |
| 181 |
% [Example puzzle \sudpuzznewline |
| 182 |
% (anything can come after the nine puzzle lines)] |
| 183 |
% \begin{figure} |
| 184 |
% \centering |
| 185 |
% \sudoku{examout.sud} |
| 186 |
% \caption{Example Sudoku puzzle}\label{fig:puz1} |
| 187 |
% \end{figure} |
| 188 |
% |
| 189 |
% Among many other sources the \emph{Sudoku Solver by logic} |
| 190 |
% website~\cite{SSBL} |
| 191 |
% provides much information on Sudoku puzzles and their solutions, |
| 192 |
% as does the \emph{Sudoku Online}~\cite{SOL} website. |
| 193 |
% |
| 194 |
% A Sudoku puzzle may be represented as a simple text file consisting |
| 195 |
% of nine rows of numbers and dots, nine numbers and dots in each row. |
| 196 |
% The numbers are the clues to the puzzle and the dots represent blanks |
| 197 |
% in the grid. A sudoko file for the example puzzle is given in |
| 198 |
% \fref{fig:file1}. |
| 199 |
% |
| 200 |
% |
| 201 |
% \begin{figure} |
| 202 |
% \centering |
| 203 |
% \begin{verbatim} |
| 204 |
% ..483..72 |
| 205 |
% .12....8. |
| 206 |
% ..52.13.. |
| 207 |
% ....62.91 |
| 208 |
% 7..5.9..3 |
| 209 |
% 94.78.... |
| 210 |
% ..39.74.. |
| 211 |
% .5....61. |
| 212 |
% .8..469.. |
| 213 |
% |
| 214 |
% Example puzzle |
| 215 |
% (anything can come after the nine puzzle lines) |
| 216 |
% \end{verbatim} |
| 217 |
% \caption{A sudoku file for the example puzzle}\label{fig:file1} |
| 218 |
% \end{figure} |
| 219 |
% |
| 220 |
% |
| 221 |
% \renewcommand*{\puzzlefile}{examout.ans} |
| 222 |
% \writepuzzle% |
| 223 |
% {694835172}% |
| 224 |
% {312674589}% |
| 225 |
% {875291364}% |
| 226 |
% {538462791}% |
| 227 |
% {726519843}% |
| 228 |
% {941783256}% |
| 229 |
% {163957428}% |
| 230 |
% {459328617}% |
| 231 |
% {287146935}% |
| 232 |
% [Solution to example puzzle] |
| 233 |
% |
| 234 |
% \begin{figure} |
| 235 |
% \centering |
| 236 |
% \cluefont{\normalsize}\cellsize{1.5\baselineskip} |
| 237 |
% \sudoku{examout.ans} |
| 238 |
% \caption{Solution to example puzzle}\label{fig:ans1} |
| 239 |
% \end{figure} |
| 240 |
% |
| 241 |
% |
| 242 |
% This manual is typeset according to the conventions of the \LaTeX{} |
| 243 |
% \textsc{docstrip} utility which enables the automatic extraction |
| 244 |
% of the \LaTeX{} macro source files~\cite{COMPANION}. |
| 245 |
% |
| 246 |
% \section{Usage} |
| 247 |
% |
| 248 |
% The bundle provides three packages; one for typesetting a puzzle, one |
| 249 |
% for solving a puzzle, and the third for generating a puzzle. Each package |
| 250 |
% requires the previous one(s). |
| 251 |
% |
| 252 |
% A file is also provided that contains over 50 puzzles and their answers --- |
| 253 |
% all you have to do is run LaTeX on it, print it, and get to work on the puzzles |
| 254 |
% (or give them to someone else). |
| 255 |
% |
| 256 |
% \subsection{Typesetting} |
| 257 |
% |
| 258 |
% The \Lpack{printsudoku} package enables you to typeset a Sudoku |
| 259 |
% puzzle given in a sudoku file. |
| 260 |
% |
| 261 |
% \DescribeMacro{\sudoku} |
| 262 |
% The command \cs{sudoku}\marg{file} typesets the sudoku puzzle from the |
| 263 |
% sudoku file named \meta{file}. |
| 264 |
% For example: \\ |
| 265 |
% \verb? \begin{center} \sudoku{puzzle1.sud} \end{center}? \\ |
| 266 |
% The command reads only the first nine lines in the file, which must |
| 267 |
% contain the puzzle's description. Anything after these lines is ignored, |
| 268 |
% so comments, such as a title or other explanatory text, |
| 269 |
% can be put at the end of the file. |
| 270 |
% |
| 271 |
% \DescribeMacro{\cluefont} |
| 272 |
% Following \cs{cluefont}\marg{font} the clues are typeset using the |
| 273 |
% \meta{font} font specification. The default is: \\ |
| 274 |
% \verb?\cluefont{\Huge}? |
| 275 |
% |
| 276 |
% \DescribeMacro{\cellsize} |
| 277 |
% The puzzle is typeset as a \LaTeX\ \Lenv{picture} and |
| 278 |
% \cs{cellsize}\marg{length} specifies the size of the cells in the grid. |
| 279 |
% To match the \cs{cluefont} the default is: \\ |
| 280 |
% \verb?\cellsize{2.5\baselineskip}? |
| 281 |
% |
| 282 |
% Figure~\ref{fig:puz1} was set using the default \cs{cluefont} and |
| 283 |
% \cs{cellsize}. On the other hand, \fref{fig:ans1} was set via: |
| 284 |
% \begin{verbatim} |
| 285 |
% \begin{figure} |
| 286 |
% \centering |
| 287 |
% \cluefont{\normalsize}\cellsize{1.5\baselineskip} |
| 288 |
% \sudoku{examout.ans} |
| 289 |
% \caption{Solution to example puzzle}\label{fig:ans1} |
| 290 |
% \end{figure} |
| 291 |
% \end{verbatim} |
| 292 |
% |
| 293 |
% \DescribeMacro{\writepuzzle} |
| 294 |
% \DescribeMacro{\puzzlefile} |
| 295 |
% \DescribeMacro{\sudpuzznewline} |
| 296 |
% The command \cs{writepuzzle}, which takes nine required arguments each of |
| 297 |
% which is a line in the puzzle, writes the puzzle to the file \cs{puzzlefile}, where the default |
| 298 |
% is: \\ |
| 299 |
% \verb?\newcommand*{\puzzlefile}{puzz.sud}? |
| 300 |
% |
| 301 |
% The nine required arguments to \cs{writepuzzle} are the lines describing |
| 302 |
% a puzzle as they would appear in a sudoku file. There is an optional tenth |
| 303 |
% argument after the nine required arguments which you may use to write |
| 304 |
% a comment at the end of the file. |
| 305 |
% For instance, earlier I used the following |
| 306 |
% to write out the example puzzle to the file \file{examout.sud}: |
| 307 |
% \begin{verbatim} |
| 308 |
% \renewcommand*{\puzzlefile}{examout.sud} |
| 309 |
% \writepuzzle% |
| 310 |
% {..483..72}% |
| 311 |
% {.12....8.}% |
| 312 |
% {..52.13..}% |
| 313 |
% {....62.91}% |
| 314 |
% {7..5.9..3}% |
| 315 |
% {94.78....}% |
| 316 |
% {..39.74..}% |
| 317 |
% {.5....61.}% |
| 318 |
% {.8..469..}% |
| 319 |
% [Example puzzle \sudpuzznewline |
| 320 |
% (anything can come after the nine puzzle lines)] |
| 321 |
% \end{verbatim} |
| 322 |
% And similarly for writing out the file with the solution. |
| 323 |
% |
| 324 |
% If you want a multiline comment, use the \cs{sudpuzznewline} macro to |
| 325 |
% start a new line (\verb?\\? or \cs{newline} will not work). |
| 326 |
% |
| 327 |
% |
| 328 |
% \subsection{Solving} |
| 329 |
% |
| 330 |
% The \Lpack{solvesudoku} package lets you use \LaTeX\ to try and solve |
| 331 |
% a Sudoku puzzle. |
| 332 |
% |
| 333 |
% \DescribeMacro{\sudokusolve} |
| 334 |
% The macro \cs{sudokusolve}\marg{file} attempts to find a solution to |
| 335 |
% the puzzle in the sudoku file \meta{file}. It uses the \Lpack{printsudoku} |
| 336 |
% package for typesetting the puzzle. |
| 337 |
% |
| 338 |
% It first prints the puzzle as given and then attempts to solve it. |
| 339 |
% The solution, or as much as was obtainable, is typeset in a smaller |
| 340 |
% font below the original. Here is the definition: |
| 341 |
% \begin{verbatim} |
| 342 |
% \newcommand*{\sudokusolve}[1]{% |
| 343 |
% \begin{center} |
| 344 |
% \sudoku{#1} |
| 345 |
% \end{center} |
| 346 |
% \getproblem{#1} |
| 347 |
% \reduceallcells \keepreducing |
| 348 |
% \writegame |
| 349 |
% \noindent\begin{minipage}{\linewidth} |
| 350 |
% THE ANSWER |
| 351 |
% \begin{center} |
| 352 |
% \cluefont{\normalsize} |
| 353 |
% \cellsize{1.5\baselineskip} |
| 354 |
% \sudoku{sud.out} |
| 355 |
% \end{center} |
| 356 |
% \end{minipage}} |
| 357 |
% \end{verbatim} |
| 358 |
% You may use the macros in \cs{sudokusolve} separately if you wish. |
| 359 |
% |
| 360 |
% \DescribeMacro{\getproblem} |
| 361 |
% \cs{getproblem}\marg{file} reads in the puzzle from the sudoku file |
| 362 |
% \meta{file} and initialises the solution. |
| 363 |
% |
| 364 |
% \DescribeMacro{\reduceallcells} |
| 365 |
% \cs{reduceallcells} takes a simple-minded approach to develop a solution |
| 366 |
% to the puzzle. |
| 367 |
% |
| 368 |
% \DescribeMacro{\keepreducing} |
| 369 |
% If \cs{reduceallcells} does not completely solve the puzzle then |
| 370 |
% \cs{keepreducing} applies increasingly sophisticated solution methods, |
| 371 |
% which may or may not lead to a complete solution. |
| 372 |
% |
| 373 |
% \DescribeMacro{\writegame} |
| 374 |
% \DescribeMacro{\sudsolnfile} |
| 375 |
% \cs{writegame} writes out a (partially) solved puzzle to the sudoku file |
| 376 |
% \cs{sudsolnfile} (default \file{sud.out}). Later this is read in again |
| 377 |
% by \cs{sudoku} to |
| 378 |
% typeset the solution. |
| 379 |
% |
| 380 |
% Here's a small example of how you might use the package. This will keep |
| 381 |
% asking on the terminal for sudoku files to solve. |
| 382 |
% \begin{verbatim} |
| 383 |
%%%% solvethem.tex Solve Sudoku files |
| 384 |
%%%% Peter Wilson |
| 385 |
% \documentclass{article} |
| 386 |
% \usepackage{solvesudoku} |
| 387 |
% \newcommand*{\solvefile}[1]{\begingroup |
| 388 |
% \sudokusolve{#1}% |
| 389 |
% \par |
| 390 |
% \vspace{\baselineskip} |
| 391 |
% Number of clues = \the\numcluesctr\ and difficulty = \the\difficultyctr. |
| 392 |
% \endgroup} |
| 393 |
% \def\yesans{y} |
| 394 |
% \begin{document} |
| 395 |
% \loop |
| 396 |
% \typein[\getans]{New file? y/n} |
| 397 |
% \ifx\yesans\getans |
| 398 |
% \typein[\sudfile]{Enter the file name} |
| 399 |
% \clearpage |
| 400 |
% \begin{center} \Huge \sudfile \end{center} |
| 401 |
% \solvefile{\sudfile} |
| 402 |
% \repeat |
| 403 |
% \end{document} |
| 404 |
% \end{verbatim} |
| 405 |
% |
| 406 |
% \DescribeMacro{\numcluesctr} |
| 407 |
% \DescribeMacro{\difficultyctr} |
| 408 |
% These are two \TeX\ \cs{count}s. \cs{numcluesctr} is the number of clues |
| 409 |
% in the initial puzzle, and \cs{difficultyctr} is a numerical indication |
| 410 |
% of how hard the solver had to work, but it doesn't really mean much |
| 411 |
% as the solver has had successes with some puzzles with a high |
| 412 |
% \cs{difficultyctr} rating |
| 413 |
% but failed to solve some with medium values of \cs{difficultyctr}. |
| 414 |
% |
| 415 |
% \subsection{Generation} |
| 416 |
% |
| 417 |
% With the \Lpack{createsudoku} package you can get \LaTeX\ to automatically |
| 418 |
% generate a Sudoku puzzle. This package does require the use of Donald |
| 419 |
% Arseneau's \Lpack{random} code~\cite{RANDOM} for generating random numbers. |
| 420 |
% |
| 421 |
% \DescribeMacro{\generategrid} |
| 422 |
% \cs{generategrid}\oarg{file} will generate a Sudoku puzzle starting with |
| 423 |
% the solution given in the sudoku file \meta{file}. If the file is |
| 424 |
% not given then it will start from a solution provided by the package. |
| 425 |
% |
| 426 |
% The puzzle is generated by taking the solution and randomly exchanging |
| 427 |
% rows and columns for some (random) number of times. Then clues are |
| 428 |
% eliminated until |
| 429 |
% it is no longer soluble by \cs{sudokusolve}. The last clue that was deleted |
| 430 |
% is put back and then the resulting grid is presented as the puzzle. |
| 431 |
% |
| 432 |
% An initial set of clues are deleted before the solver is called. It can |
| 433 |
% happen that the puzzle even then is too difficult for the solver, so |
| 434 |
% you have to check the solution as presented is a complete one for the puzzle. |
| 435 |
% |
| 436 |
% \DescribeMacro{\genfile} |
| 437 |
% \DescribeMacro{\prevfile} |
| 438 |
% \DescribeMacro{\currfile} |
| 439 |
% The generated puzzle, and its solution, is typeset and the puzzle is |
| 440 |
% also output in the sudoku file \cs{genfile}. The default is: \\ |
| 441 |
% \verb?\newcommand*{\genfile}{gensud.sud}? \\ |
| 442 |
% Two temporary sudoku files, \cs{prevfile} and \cs{currfile}, are |
| 443 |
% used during the generation. The defaults are: \\ |
| 444 |
% \verb?\newcommand*{\prevfile}{genprev.sdx}? \\ |
| 445 |
% \verb?\newcommand*{\currfile}{gencurr.sdx}? \\ |
| 446 |
% A pre-existing version of any of these three files will be overwritten. |
| 447 |
% |
| 448 |
% \DescribeMacro{\setsudrandom} |
| 449 |
% The random number generater is initialised via a seed based on |
| 450 |
% a number (the internal value of \cs{randomi}) |
| 451 |
% in the range $-1 \leq$ \cs{randomi} $\leq 2147483646$. |
| 452 |
% If its value is -1 (set via \verb?\setsudrandom{-1}?) then the actual |
| 453 |
% seed will be calculated based on the time and date. For any given |
| 454 |
% seed the sequence of the generated random numbers is the same. |
| 455 |
% The value of the |
| 456 |
% seed is output via a \cs{typeout} if you need to repeat a generation. |
| 457 |
% |
| 458 |
% You should not attempt to set \cs{randomi} directly but use |
| 459 |
% \cs{setsudrandom}\marg{num}. |
| 460 |
% |
| 461 |
% The default setting is: \\ |
| 462 |
% \verb?\setsudrandom{-1}? \\ |
| 463 |
% and as that means that the seed depends on the time and date, |
| 464 |
% a new puzzle will be |
| 465 |
% generated each time (unless the time interval is very short). The |
| 466 |
% maximum number of puzzles that can be generated from one initial solution |
| 467 |
% is 2,147,483,646 which is the range of the random number generator. |
| 468 |
% |
| 469 |
% \DescribeMacro{\initialelimination} |
| 470 |
% The macro \cs{initialelimination} eliminates an initial set of solutions |
| 471 |
% from the randomized starting grid. Various predefined sets are provided |
| 472 |
% and you can either provide your own definition for \cs{initialelimination} |
| 473 |
% or \cs{let} it to one of the predefined sets, e.g., \\ |
| 474 |
% \verb?\let\initialelimination\elimcrossandnines? |
| 475 |
% |
| 476 |
% \DescribeMacro{\elimseventeen} |
| 477 |
% \DescribeMacro{\elimnum} |
| 478 |
% \DescribeMacro{\elimcross} |
| 479 |
% \DescribeMacro{\elimex} |
| 480 |
% \DescribeMacro{\elimcrossandnines} |
| 481 |
% \DescribeMacro{\elimcrossandex} |
| 482 |
% \DescribeMacro{\elimcrossandexandnines} |
| 483 |
% \cs{elimseventeen} randomly eliminates 17 solutions from the grid --- |
| 484 |
% apparently the solution to a puzzle can be ambiguous if two numbers |
| 485 |
% are completely absent. |
| 486 |
% \cs{elimnum}\marg{num} eliminates every solution \meta{num} |
| 487 |
% (e.g. \verb?\elimnum{7}? will eliminate every 7 from the grid). |
| 488 |
% \cs{elimcross} eliminates all numbers from column 5 and from row 5, while |
| 489 |
% \cs{elimex} eliminates all numbers on the diagonals. |
| 490 |
% |
| 491 |
% \cs{elimcrossandnines} |
| 492 |
% is a combination of \cs{elimcross} and \verb?\elimnum{9}?. Similarly the |
| 493 |
% macros \cs{elimcrossandex} and \cs{elimcrossandexandnines} are combinations |
| 494 |
% of some of the earlier macros. |
| 495 |
% |
| 496 |
% |
| 497 |
% |
| 498 |
% \StopEventually{ |
| 499 |
% \bibliographystyle{alpha} |
| 500 |
% \begingroup |
| 501 |
% \raggedright |
| 502 |
% \begin{thebibliography}{GMSN94A} |
| 503 |
% |
| 504 |
% \bibitem[Abr05]{SUDOKU} |
| 505 |
% Paul Abraham. |
| 506 |
% \newblock \emph{The sudoku package}. |
| 507 |
% \newblock June 2005. |
| 508 |
% \newblock (Available from CTAN in |
| 509 |
% \texttt{macros/latex/contrib/sudoku}) |
| 510 |
% |
| 511 |
% \bibitem[Ars95]{RANDOM} |
| 512 |
% Donald Arseneau. |
| 513 |
% \newblock \emph{Generating random numbers in \TeX}. |
| 514 |
% \newblock 1995. |
| 515 |
% \newblock (Available from CTAN in |
| 516 |
% \texttt{macros/generic/random.tex}) |
| 517 |
% |
| 518 |
% |
| 519 |
% \bibitem[MG04]{COMPANION} |
| 520 |
% Frank Mittelbach and Michel Goossens. |
| 521 |
% \newblock \emph{The LaTeX Companion}. |
| 522 |
% \newblock Second edition. |
| 523 |
% \newblock Addison-Wesley Publishing Company, 2004. |
| 524 |
% \newblock \textsc{isbn} 0-201-36299-6. |
| 525 |
% |
| 526 |
% \bibitem[PJ05]{PRACTEX} |
| 527 |
% \TeX\ Users Group. |
| 528 |
% \newblock Distractions: Sudoku. |
| 529 |
% \newblock \emph{The PracTeX Journal}. |
| 530 |
% \newblock 2005-4. |
| 531 |
% \newblock \url{http://tug.org/pracjourn2005-4/distract} |
| 532 |
% |
| 533 |
% \bibitem[SOL]{SOL} |
| 534 |
% \emph{Sudoku Online: Home of the Sudokulist}. |
| 535 |
% \newblock \url{http://www.sudoku.org.uk} |
| 536 |
% |
| 537 |
% \bibitem[SSBL]{SSBL} |
| 538 |
% \emph{Sudoku Solver ... by logic}. |
| 539 |
% \newblock \url{http://www.sudokusolver.co.uk} |
| 540 |
% |
| 541 |
% |
| 542 |
% ^^A \bibitem[Wil04]{MEMOIR} |
| 543 |
% ^^A Peter Wilson. |
| 544 |
% ^^A \newblock \emph{The LaTeX \Lpack{memoir} class for configurable |
| 545 |
% ^^A typesetting: Source code}. |
| 546 |
% ^^A \newblock January 2004. |
| 547 |
% ^^A \newblock (Available from CTAN in |
| 548 |
% ^^A \texttt{macros/latex/contrib/memoir}) |
| 549 |
% |
| 550 |
% |
| 551 |
% \end{thebibliography} |
| 552 |
% \endgroup |
| 553 |
% |
| 554 |
% \PrintIndex |
| 555 |
% } |
| 556 |
% |
| 557 |
% \section{Code} |
| 558 |
% |
| 559 |
% \subsection{The \Lpack{printsudoku} package} |
| 560 |
% |
| 561 |
% \begin{macrocode} |
| 562 |
%<*print> |
| 563 |
\NeedsTeXFormat{LaTeX2e} |
| 564 |
\ProvidesPackage{printsudoku}[2006/02/16 v1.0 typeset sudoku puzzles] |
| 565 |
|
| 566 |
% \end{macrocode} |
| 567 |
% |
| 568 |
% \begin{macro}{\s@dread} |
| 569 |
% \begin{macro}{\s@dwrite} |
| 570 |
% We are going to be reading and writing some files. |
| 571 |
% \begin{macrocode} |
| 572 |
\newread\s@dread |
| 573 |
\newwrite\s@dwrite |
| 574 |
|
| 575 |
% \end{macrocode} |
| 576 |
% \end{macro} |
| 577 |
% \end{macro} |
| 578 |
% |
| 579 |
% \begin{macro}{\reads@dgame} |
| 580 |
% \cs{reads@dgame}\marg{file} opens a sudoku file \meta{file} for reading. |
| 581 |
% \begin{macrocode} |
| 582 |
%%%% open game file |
| 583 |
\newcommand*{\reads@dgame}[1]{% |
| 584 |
\closein\s@dread |
| 585 |
\openin\s@dread=#1} |
| 586 |
|
| 587 |
% \end{macrocode} |
| 588 |
% \end{macro} |
| 589 |
% |
| 590 |
% \begin{macro}{\halfs@dcell} |
| 591 |
% \begin{macro}{\cellsize} |
| 592 |
% \begin{macro}{\cluefont} |
| 593 |
% We're going to use a \Lenv{picture} environment for drawing the grid, |
| 594 |
% and to keep numbers neatly we'll use the length \cs{halfs@dcell} as |
| 595 |
% the \cs{unitlength}. \cs{cellsize}\marg{length} is the use command for |
| 596 |
% setting the size of a cell. The clues are typeset using the \cs{cluefont} |
| 597 |
% font. |
| 598 |
% \begin{macrocode} |
| 599 |
%%% set size of a game cell |
| 600 |
\newlength\halfs@dcell |
| 601 |
\newcommand*{\cellsize}[1]{% |
| 602 |
\halfs@dcell=#1\relax |
| 603 |
\halfs@dcell=0.5\halfs@dcell} |
| 604 |
\cellsize{2.5\baselineskip} |
| 605 |
%% set font for the numbers |
| 606 |
\newcommand*{\cluefont}[1]{\def\s@dfont{#1}} |
| 607 |
\cluefont{\Huge} |
| 608 |
|
| 609 |
% \end{macrocode} |
| 610 |
% \end{macro} |
| 611 |
% \end{macro} |
| 612 |
% \end{macro} |
| 613 |
% |
| 614 |
% \begin{macro}{\s@dncol} |
| 615 |
% \begin{macro}{\s@dnrow} |
| 616 |
% \begin{macro}{\s@dcolpos} |
| 617 |
% \begin{macro}{\s@drowpos} |
| 618 |
% Counts for looping and cell positions |
| 619 |
% \begin{macrocode} |
| 620 |
%% counts for looping and cell positions |
| 621 |
\newcount\s@dncol |
| 622 |
\newcount\s@dnrow |
| 623 |
\newcount\s@dcolpos |
| 624 |
\newcount\s@drowpos |
| 625 |
|
| 626 |
% \end{macrocode} |
| 627 |
% \end{macro} |
| 628 |
% \end{macro} |
| 629 |
% \end{macro} |
| 630 |
% \end{macro} |
| 631 |
% |
| 632 |
% \begin{macro}{\adds@dclues} |
| 633 |
% \cs{adds@dclues} inserts the clues into the game grid. It reads the |
| 634 |
% sudoku file line by line insert the clues into the grid for one line |
| 635 |
% before going on to the next line. |
| 636 |
% \begin{macrocode} |
| 637 |
%% insert the clues into the game array |
| 638 |
\newcommand*{\adds@dclues}{% |
| 639 |
\firsts@dcluetrue |
| 640 |
\s@dnrow\@ne |
| 641 |
\loop |
| 642 |
\ifnum\s@dnrow<10\relax |
| 643 |
\read\s@dread to \s@dline |
| 644 |
\firsts@dcluetrue |
| 645 |
\s@drowpos=\s@dnrow |
| 646 |
\multiply\s@drowpos\tw@ |
| 647 |
\advance\s@drowpos\m@ne |
| 648 |
\s@dncol\@ne |
| 649 |
\dos@dcols |
| 650 |
\advance\s@dnrow\@ne |
| 651 |
\repeat |
| 652 |
\closein\s@dread} |
| 653 |
|
| 654 |
% \end{macrocode} |
| 655 |
% \end{macro} |
| 656 |
% |
| 657 |
% \begin{macro}{\dos@dcols} |
| 658 |
% \cs{dos@dcols} inserts one row of clues into the game grid. |
| 659 |
% \begin{macrocode} |
| 660 |
%% insert a row of clues |
| 661 |
\newcommand*{\dos@dcols}{% |
| 662 |
\bgroup |
| 663 |
\loop |
| 664 |
\ifnum\s@dncol<10\relax |
| 665 |
\s@dcolpos=\s@dncol |
| 666 |
\multiply\s@dcolpos\tw@ |
| 667 |
\advance\s@dcolpos\m@ne |
| 668 |
\put(\s@dcolpos,-\s@drowpos){\makebox(0,0){\s@dfont\gets@dclue}}% |
| 669 |
\advance\s@dncol\@ne |
| 670 |
\repeat |
| 671 |
\egroup} |
| 672 |
|
| 673 |
% \end{macrocode} |
| 674 |
% \end{macro} |
| 675 |
% |
| 676 |
% \begin{macro}{\gettwo} |
| 677 |
% \begin{macro}{\nowt} |
| 678 |
% \begin{macro}{\istchar} |
| 679 |
% \begin{macro}{\restchars} |
| 680 |
% \begin{macro}{\splitoff} |
| 681 |
% \cs{splitoff}\marg{string} gets the next character in a string. The next |
| 682 |
% character is made available as \cs{istchar} and the remainder of the |
| 683 |
% string as \cs{restchars}. This is explained in a forthcoming |
| 684 |
% \emph{Glisterings} column in \emph{TUGboat}. |
| 685 |
% \begin{macrocode} |
| 686 |
%% get the next character in a string |
| 687 |
\def\gettwo#1#2\nowt{% |
| 688 |
\gdef\istchar{#1}\gdef\restchars{#2}} |
| 689 |
\def\splitoff#1{\gettwo#1\nowt} |
| 690 |
% \end{macrocode} |
| 691 |
% \end{macro} |
| 692 |
% \end{macro} |
| 693 |
% \end{macro} |
| 694 |
% \end{macro} |
| 695 |
% \end{macro} |
| 696 |
% |
| 697 |
% \begin{macro}{\s@dfstop} |
| 698 |
% We use this for checking if a character extracted from a string is a `.'. |
| 699 |
% \begin{macrocode} |
| 700 |
%% a full stop (period) |
| 701 |
\gdef\s@dfstop{.} |
| 702 |
|
| 703 |
% \end{macrocode} |
| 704 |
% \end{macro} |
| 705 |
% |
| 706 |
% \begin{macro}{\iffirsts@dclue} |
| 707 |
% \begin{macro}{\firsts@dcluetrue} |
| 708 |
% \begin{macro}{\firsts@dcluefalse} |
| 709 |
% \begin{macro}{\gets@dclue} |
| 710 |
% \cs{gets@dclue} gets the next clue (character) from a line of clues. |
| 711 |
% We do slightly different things if we are dealing with the first clue |
| 712 |
% or the others. |
| 713 |
% \begin{macrocode} |
| 714 |
%% get the next clue in the line |
| 715 |
\newif\iffirsts@dclue |
| 716 |
\firsts@dcluetrue |
| 717 |
\newcommand*{\gets@dclue}{% |
| 718 |
\iffirsts@dclue |
| 719 |
\expandafter\splitoff\expandafter{\s@dline}% |
| 720 |
\global\firsts@dcluefalse |
| 721 |
\else |
| 722 |
\expandafter\splitoff\expandafter{\restchars}% |
| 723 |
\fi |
| 724 |
\ifx\s@dfstop\istchar |
| 725 |
\else |
| 726 |
\istchar |
| 727 |
\fi} |
| 728 |
|
| 729 |
% \end{macrocode} |
| 730 |
% \end{macro} |
| 731 |
% \end{macro} |
| 732 |
% \end{macro} |
| 733 |
% \end{macro} |
| 734 |
% |
| 735 |
% \begin{macro}{\s@dgame} |
| 736 |
% \cs{s@dgame} typesets the grid, then adds in the clues. |
| 737 |
% \begin{macrocode} |
| 738 |
%% typeset the grid, then add the clues |
| 739 |
\newcommand*{\s@dgame}{% |
| 740 |
\setlength\unitlength\halfs@dcell |
| 741 |
\begin{picture}(18,18)(0,-18) |
| 742 |
\thinlines |
| 743 |
\multiput(0,0)(2,0){10}{\line(0,-1){18}} |
| 744 |
\multiput(0,0)(0,-2){10}{\line(1,0){18}} |
| 745 |
\thicklines \linethickness{1pt} |
| 746 |
\multiput(0,0)(6,0){4}{\line(0,-1){18}} |
| 747 |
\multiput(0,0)(0,-6){4}{\line(1,0){18}} |
| 748 |
\adds@dclues |
| 749 |
\end{picture}} |
| 750 |
|
| 751 |
% \end{macrocode} |
| 752 |
% \end{macro} |
| 753 |
% |
| 754 |
% \begin{macro}{\sudoku} |
| 755 |
% \cs{sudoku}\marg{file} reads a game from \meta{file} and then typesets it. |
| 756 |
% \begin{macrocode} |
| 757 |
%% the whole shebang, where #1 is the name of the game file |
| 758 |
\newcommand*{\sudoku}[1]{% |
| 759 |
\reads@dgame{#1}% |
| 760 |
\s@dgame} |
| 761 |
|
| 762 |
% \end{macrocode} |
| 763 |
% \end{macro} |
| 764 |
% |
| 765 |
% \begin{macro}{\puzzlefile} |
| 766 |
% \begin{macro}{\writepuzzle} |
| 767 |
% \begin{macro}{\writes@dpuzzend} |
| 768 |
% \begin{macro}{\sudpuzznewline} |
| 769 |
% \cs{writepuzzle} takes nine arguments --- the nine lines specifying a puzzle |
| 770 |
% --- and writes them to the \cs{puzzlefile} file. |
| 771 |
% |
| 772 |
% \cs{writes@dpuzzend}\oarg{comment} writes \meta{comment} at the end of the |
| 773 |
% \cs{puzzlefile} file. |
| 774 |
% |
| 775 |
% \cs{sudpuzznewline} provides a \cs{newline} macro for use in a comment being |
| 776 |
% written to a puzzle file. |
| 777 |
% \begin{macrocode} |
| 778 |
\newcommand*{\puzzlefile}{puzz.sud} |
| 779 |
\newcommand*{\writepuzzle}[9]{% |
| 780 |
\immediate\closeout\s@dwrite |
| 781 |
\immediate\openout\s@dwrite=\puzzlefile |
| 782 |
\immediate\write\s@dwrite{#1}% |
| 783 |
\immediate\write\s@dwrite{#2}% |
| 784 |
\immediate\write\s@dwrite{#3}% |
| 785 |
\immediate\write\s@dwrite{#4}% |
| 786 |
\immediate\write\s@dwrite{#5}% |
| 787 |
\immediate\write\s@dwrite{#6}% |
| 788 |
\immediate\write\s@dwrite{#7}% |
| 789 |
\immediate\write\s@dwrite{#8}% |
| 790 |
\immediate\write\s@dwrite{#9}% |
| 791 |
\writes@dpuzzend} |
| 792 |
\newcommand*{\writes@dpuzzend}[1][\@empty]{ |
| 793 |
\ifx\@empty #1\else |
| 794 |
\immediate\write\s@dwrite{ }% |
| 795 |
\immediate\write\s@dwrite{#1}% |
| 796 |
\fi |
| 797 |
\immediate\closeout\s@dwrite} |
| 798 |
\newcommand*{\sudpuzznewline}{^^J} |
| 799 |
|
| 800 |
% \end{macrocode} |
| 801 |
% \end{macro} |
| 802 |
% \end{macro} |
| 803 |
% \end{macro} |
| 804 |
% \end{macro} |
| 805 |
% |
| 806 |
% The end of the package. |
| 807 |
% \begin{macrocode} |
| 808 |
%</print> |
| 809 |
% \end{macrocode} |
| 810 |
% |
| 811 |
% \subsection{The \Lpack{solvesudoku} package} |
| 812 |
% |
| 813 |
% The package requires the \Lpack{printsudoku} package to do some puzzle |
| 814 |
% typesetting. |
| 815 |
% |
| 816 |
% \begin{macrocode} |
| 817 |
%<*solve> |
| 818 |
\NeedsTeXFormat{LaTeX2e} |
| 819 |
\ProvidesPackage{solvesudoku}[2006/02/16 v1.0 solve sudoku puzzles] |
| 820 |
\RequirePackage{printsudoku} |
| 821 |
|
| 822 |
% \end{macrocode} |
| 823 |
% |
| 824 |
% \subsubsection{Setup} |
| 825 |
% |
| 826 |
% \begin{macro}{\commentary} |
| 827 |
% It can be useful to control the amount of output to the log file. |
| 828 |
% \begin{macrocode} |
| 829 |
\newcommand{\commentary}[1]{\typeout{#1}} |
| 830 |
|
| 831 |
% \end{macrocode} |
| 832 |
% \end{macro} |
| 833 |
% |
| 834 |
% The following counts are defined in the \Lpack{printsudoku} package: \\ |
| 835 |
% \verb?\s@dncol, \s@dnrow, \s@dcolpos, \s@drowpos? |
| 836 |
% |
| 837 |
% \begin{macro}{\s@lcnta} |
| 838 |
% \begin{macro}{\solcnt} |
| 839 |
% \begin{macro}{\tenscnt} |
| 840 |
% \begin{macro}{\tempcntz} |
| 841 |
% \begin{macro}{\tempcnty} |
| 842 |
% \begin{macro}{\tmpsetctr} |
| 843 |
% \begin{macro}{\tmpsetansctr} |
| 844 |
% \begin{macro}{\boxctr} |
| 845 |
% \begin{macro}{\sumctr} |
| 846 |
% \begin{macro}{\toprangectr} |
| 847 |
% A bunch of \cs{count}s. They could probably be reduced in number |
| 848 |
% but they help me to keep the code less mysterious. |
| 849 |
% \begin{macrocode} |
| 850 |
%%% too many counts, maybe they should be reduced |
| 851 |
\newcount\s@lcnta % a cell number |
| 852 |
\newcount\solcnt % number of solved cells |
| 853 |
\newcount\settonumcnt |
| 854 |
\newcount\tenscnt |
| 855 |
\newcount\tempcntz |
| 856 |
\newcount\tempcnty |
| 857 |
\newcount\tmpsetctr |
| 858 |
\newcount\tmpsetansctr |
| 859 |
\newcount\boxctr |
| 860 |
\newcount\sumctr |
| 861 |
\newcount\toprangectr |
| 862 |
% \end{macrocode} |
| 863 |
% \end{macro} |
| 864 |
% \end{macro} |
| 865 |
% \end{macro} |
| 866 |
% \end{macro} |
| 867 |
% \end{macro} |
| 868 |
% \end{macro} |
| 869 |
% \end{macro} |
| 870 |
% \end{macro} |
| 871 |
% \end{macro} |
| 872 |
% \end{macro} |
| 873 |
% |
| 874 |
% \begin{macro}{\lonecellctr} |
| 875 |
% \begin{macro}{\reducedctr} |
| 876 |
% \begin{macro}{\numlistctr} |
| 877 |
% \begin{macro}{\difficultyctr} |
| 878 |
% \begin{macro}{\s@dtempcnta} |
| 879 |
% \begin{macro}{\s@dtempcntb} |
| 880 |
% \begin{macro}{\s@dtemploopcnta} |
| 881 |
% \begin{macro}{\maxrangectr} |
| 882 |
% \begin{macro}{\asetctr} |
| 883 |
% \begin{macro}{\secondctr} |
| 884 |
% \begin{macrocode} |
| 885 |
\newcount\lonecellctr |
| 886 |
\newcount\reducedctr |
| 887 |
\newcount\numlistctr |
| 888 |
\newcount\difficultyctr |
| 889 |
\newcount\s@dtempcnta |
| 890 |
\newcount\s@dtempcntb |
| 891 |
\newcount\s@dtemploopcnta |
| 892 |
\newcount\maxrangectr |
| 893 |
\newcount\asetctr |
| 894 |
\newcount\secondctr |
| 895 |
% \end{macrocode} |
| 896 |
% \end{macro} |
| 897 |
% \end{macro} |
| 898 |
% \end{macro} |
| 899 |
% \end{macro} |
| 900 |
% \end{macro} |
| 901 |
% \end{macro} |
| 902 |
% \end{macro} |
| 903 |
% \end{macro} |
| 904 |
% \end{macro} |
| 905 |
% \end{macro} |
| 906 |
% |
| 907 |
% \begin{macro}{\digitictr} |
| 908 |
% \begin{macro}{\digitiictr} |
| 909 |
% \begin{macro}{\numdigitsctr} |
| 910 |
% \begin{macro}{\numcluesctr} |
| 911 |
% \begin{macrocode} |
| 912 |
\newcount\digitictr |
| 913 |
\newcount\digitiictr |
| 914 |
\newcount\numdigitsctr |
| 915 |
\newcount\numcluesctr |
| 916 |
|
| 917 |
% \end{macrocode} |
| 918 |
% \end{macro} |
| 919 |
% \end{macro} |
| 920 |
% \end{macro} |
| 921 |
% \end{macro} |
| 922 |
% |
| 923 |
% \begin{macro}{\iffirsts@dclue} |
| 924 |
% \begin{macro}{\iffirstchar} |
| 925 |
% \begin{macro}{\ifnotgotthechar} |
| 926 |
% \begin{macro}{\ifsetchanged} |
| 927 |
% \begin{macro}{\ifchanged} |
| 928 |
% \begin{macro}{\ifanychanged} |
| 929 |
% \begin{macro}{\iflonerchanged} |
| 930 |
% \begin{macro}{\ifstilldigits} |
| 931 |
% \begin{macro}{\ifkeepon} |
| 932 |
% \begin{macro}{\ifpairchanged} |
| 933 |
% \begin{macrocode} |
| 934 |
%%% \iffirsts@dclue% defined in printsudoku package |
| 935 |
\newif\iffirstchar |
| 936 |
\newif\ifnotgotthechar |
| 937 |
\newif\ifsetchanged |
| 938 |
\newif\ifchanged |
| 939 |
\newif\ifanychange |
| 940 |
\newif\iflonerchanged |
| 941 |
\newif\ifstilldigits |
| 942 |
\newif\ifkeepon |
| 943 |
\newif\ifpairchanged |
| 944 |
|
| 945 |
% \end{macrocode} |
| 946 |
% \end{macro} |
| 947 |
% \end{macro} |
| 948 |
% \end{macro} |
| 949 |
% \end{macro} |
| 950 |
% \end{macro} |
| 951 |
% \end{macro} |
| 952 |
% \end{macro} |
| 953 |
% \end{macro} |
| 954 |
% \end{macro} |
| 955 |
% \end{macro} |
| 956 |
% |
| 957 |
% \begin{macro}{\newknt} |
| 958 |
% \begin{macro}{\useknt} |
| 959 |
% \begin{macro}{\createsudsets} |
| 960 |
% \cs{newknt}\marg{name} creates a new count \cs{name}, which can include |
| 961 |
% analphabetic characters. \cs{useknt}\marg{name} calls the \cs{name} count. |
| 962 |
% These are like the \LaTeX\ kernel \cs{@namedef} and \cs{@nameuse}. |
| 963 |
% In particular we will use 81 `numbered' counts, one for each cell |
| 964 |
% in the sudoku grid, using \cs{createsudsets} to generate them. |
| 965 |
% \begin{macrocode} |
| 966 |
%% create and use a numbered count |
| 967 |
%% we'll use 81 of these, one for each cell in the grid |
| 968 |
\newcommand*{\newknt}[1]{\expandafter\newcount\csname #1\endcsname} |
| 969 |
\newcommand*{\useknt}[1]{\csname #1\endcsname} |
| 970 |
%% create potential answer sets |
| 971 |
\newcommand*{\createsudsets}{% |
| 972 |
\global\s@lcnta\@ne |
| 973 |
\global\solcnt\z@ |
| 974 |
\loop |
| 975 |
\ifnum\s@lcnta<82\relax |
| 976 |
\newknt{s@lans\the\s@lcnta}% |
| 977 |
\advance\s@lcnta\@ne |
| 978 |
\repeat} |
| 979 |
\createsudsets |
| 980 |
|
| 981 |
% \end{macrocode} |
| 982 |
% \end{macro} |
| 983 |
% \end{macro} |
| 984 |
% \end{macro} |
| 985 |
% |
| 986 |
% \subsubsection{Binary solution sets} |
| 987 |
% |
| 988 |
% The major concern was deciding on the datastructure for the problem |
| 989 |
% (the value of \verb?\useknt{\s@lans\the\s@lcnta}}? for the \cs{s@lcnta} cell). |
| 990 |
% In the end I used a 9 digit `binary solution set' for the potential |
| 991 |
% solutions for |
| 992 |
% each cell. ($[111111111] \leftrightarrow 123456789$ and |
| 993 |
% $[101010101] \leftrightarrow 13579$). A cell |
| 994 |
% solution, say N, is represented as the `set' -N (e.g., a |
| 995 |
% potential solution 3 is represented as $[001000000]$ and the actual solution |
| 996 |
% 3 is represented by $[-3]$). |
| 997 |
% |
| 998 |
% |
| 999 |
% \begin{macro}{\initialisesuddata} |
| 1000 |
% This sets each of the 81 cells to 111111111. |
| 1001 |
% \begin{macrocode} |
| 1002 |
%% initialise potential answer sets |
| 1003 |
\newcommand*{\initialisesuddata}{\bgroup |
| 1004 |
\global\s@lcnta\@ne |
| 1005 |
\global\solcnt\z@ |
| 1006 |
\global\difficultyctr\z@ |
| 1007 |
\global\numcluesctr\z@ |
| 1008 |
\loop |
| 1009 |
\ifnum\s@lcnta<82\relax |
| 1010 |
\global\useknt{s@lans\the\s@lcnta}=111111111\relax |
| 1011 |
\advance\s@lcnta\@ne |
| 1012 |
\repeat |
| 1013 |
\egroup} |
| 1014 |
|
| 1015 |
% \end{macrocode} |
| 1016 |
% \end{macro} |
| 1017 |
% |
| 1018 |
% \begin{macrocode} |
| 1019 |
%%%%%%%%%%%%%%%%%%%%%%%% utility macros for `binary solution sets' %%%%%%%%%%%%%%%% |
| 1020 |
|
| 1021 |
% \end{macrocode} |
| 1022 |
% |
| 1023 |
% \begin{macro}{\settonum} |
| 1024 |
% \cs{settonum}\marg{set}\marg{cnt} converts a potential solution |
| 1025 |
% binary set \meta{set} to the corresponding set of digits; that is |
| 1026 |
% \verb?[11....1] -> 12...9?. The result of the conversion is assigned |
| 1027 |
% to the \cs{count} \meta{cnt} which must be supplied by the calling macro. |
| 1028 |
% If the set is negative then the result is that number |
| 1029 |
% (e.g.\verb?[-3] -> -3?). If the set contains only a single non-zero |
| 1030 |
% entry, that is converted to the negative of the corresponding digit |
| 1031 |
% (e.g. \verb?[100] -> -7?). |
| 1032 |
% |
| 1033 |
% \begin{macrocode} |
| 1034 |
%%\settonum{110011...}{cnt} |
| 1035 |
%% converts a potential solution set to a number ([11....1] -> 12...9) |
| 1036 |
%% returns the input if it is negative ([-3] -> -3) |
| 1037 |
%% returns a negative number if the set represents a single digit ([10] -> -8) |
| 1038 |
\newcommand*{\settonum}[2]{% |
| 1039 |
\settonumcnt=#1\relax |
| 1040 |
\tempcnty=\z@ |
| 1041 |
\tenscnt=\@ne |
| 1042 |
\ifnum\settonumcnt<\z@ % just return the number |
| 1043 |
\tempcnty=\settonumcnt |
| 1044 |
#2=\tempcnty |
| 1045 |
\else |
| 1046 |
\ifodd\settonumcnt % 9 flagged |
| 1047 |
\tempcntz=9\relax |
| 1048 |
\multiply\tempcntz \tenscnt |
| 1049 |
\advance \tempcnty by \tempcntz |
| 1050 |
\multiply\tenscnt 10\relax |
| 1051 |
\fi |
| 1052 |
\divide\settonumcnt by 10\relax |
| 1053 |
\ifodd\settonumcnt % 8 flagged |
| 1054 |
\tempcntz=8\relax |
| 1055 |
\multiply\tempcntz \tenscnt |
| 1056 |
\advance \tempcnty \tempcntz |
| 1057 |
\multiply\tenscnt 10\relax |
| 1058 |
\fi |
| 1059 |
\divide\settonumcnt by 10\relax |
| 1060 |
\ifodd\settonumcnt % 7 flagged |
| 1061 |
\tempcntz=7\relax |
| 1062 |
\multiply\tempcntz \tenscnt |
| 1063 |
\advance \tempcnty \tempcntz |
| 1064 |
\multiply\tenscnt 10\relax |
| 1065 |
\fi |
| 1066 |
\divide\settonumcnt by 10\relax |
| 1067 |
\ifodd\settonumcnt % 6 flagged |
| 1068 |
\tempcntz=6\relax |
| 1069 |
\multiply\tempcntz \tenscnt |
| 1070 |
\advance \tempcnty \tempcntz |
| 1071 |
\multiply\tenscnt 10\relax |
| 1072 |
\fi |
| 1073 |
\divide\settonumcnt by 10\relax |
| 1074 |
\ifodd\settonumcnt % 5 flagged |
| 1075 |
\tempcntz=5\relax |
| 1076 |
\multiply\tempcntz \tenscnt |
| 1077 |
\advance \tempcnty \tempcntz |
| 1078 |
\multiply\tenscnt 10\relax |
| 1079 |
\fi |
| 1080 |
\divide\settonumcnt by 10\relax |
| 1081 |
\ifodd\settonumcnt % 4 flagged |
| 1082 |
\tempcntz=4\relax |
| 1083 |
\multiply\tempcntz \tenscnt |
| 1084 |
\advance \tempcnty \tempcntz |
| 1085 |
\multiply\tenscnt 10\relax |
| 1086 |
\fi |
| 1087 |
\divide\settonumcnt by 10\relax |
| 1088 |
\ifodd\settonumcnt % 3 flagged |
| 1089 |
\tempcntz=3\relax |
| 1090 |
\multiply\tempcntz \tenscnt |
| 1091 |
\advance \tempcnty \tempcntz |
| 1092 |
\multiply\tenscnt 10\relax |
| 1093 |
\fi |
| 1094 |
\divide\settonumcnt by 10\relax |
| 1095 |
\ifodd\settonumcnt % 2 flagged |
| 1096 |
\tempcntz=2\relax |
| 1097 |
\multiply\tempcntz \tenscnt |
| 1098 |
\advance \tempcnty \tempcntz |
| 1099 |
\multiply\tenscnt 10\relax |
| 1100 |
\fi |
| 1101 |
\divide\settonumcnt by 10\relax |
| 1102 |
\ifodd\settonumcnt % 1 flagged |
| 1103 |
\tempcntz=1\relax |
| 1104 |
\multiply\tempcntz \tenscnt |
| 1105 |
\advance \tempcnty \tempcntz |
| 1106 |
%% \multiply\tenscnt 10\relax |
| 1107 |
\fi |
| 1108 |
\ifnum \tempcnty<10 |
| 1109 |
\ifnum\tempcnty>\z@ |
| 1110 |
\tempcnty = -\tempcnty |
| 1111 |
\fi |
| 1112 |
\fi |
| 1113 |
#2=\tempcnty |
| 1114 |
\fi} |
| 1115 |
|
| 1116 |
% \end{macrocode} |
| 1117 |
% \end{macro} |
| 1118 |
% |
| 1119 |
% \begin{macro}{\numofnuminset} |
| 1120 |
% \cs{numofnuminset}\marg{digit}\marg{set}\marg{cnt} set the \cs{count} |
| 1121 |
% \meta{cnt}to the number of times the digit \meta{digit} is represented |
| 1122 |
% in the binary set \meta{set}. For example, the number of digits in the set |
| 1123 |
% \verb?[200000013]? are \verb?1 -> 2?, \verb?2 -> 0?, \verb?...?, |
| 1124 |
% \verb?8 -> 1? and \verb?9 -> 3?. |
| 1125 |
% \begin{macrocode} |
| 1126 |
%%\numofnuminset{digit}{set}{returnctr} |
| 1127 |
%% returns the number of times digit is represented in the set |
| 1128 |
%% e.g. if the set is [200000013] then 1 -> 2, 2 -> 0,... 8 -> 1, 9 -> 3 |
| 1129 |
\newcommand*{\numofnuminset}[3]{% |
| 1130 |
\tmpsetctr=#2\relax |
| 1131 |
\tmpsetansctr=\tmpsetctr |
| 1132 |
\ifnum\tmpsetctr<\z@% solution, not a set |
| 1133 |
\tmpsetansctr=\z@ |
| 1134 |
\else |
| 1135 |
\ifcase #1\relax |
| 1136 |
\or % 1 |
| 1137 |
\divide\tmpsetansctr by 100000000\relax |
| 1138 |
\or % 2 |
| 1139 |
\divide\tmpsetansctr by 10000000\relax |
| 1140 |
\tmpsetctr=\tmpsetansctr |
| 1141 |
\divide\tmpsetctr 10\relax \multiply\tmpsetctr 10\relax |
| 1142 |
\advance\tmpsetansctr -\tmpsetctr |
| 1143 |
\or % 3 |
| 1144 |
\divide\tmpsetansctr by 1000000\relax |
| 1145 |
\tmpsetctr=\tmpsetansctr |
| 1146 |
\divide\tmpsetctr 10\relax \multiply\tmpsetctr 10\relax |
| 1147 |
\advance\tmpsetansctr -\tmpsetctr |
| 1148 |
\or % 4 |
| 1149 |
\divide\tmpsetansctr by 100000\relax |
| 1150 |
\tmpsetctr=\tmpsetansctr |
| 1151 |
\divide\tmpsetctr 10\relax \multiply\tmpsetctr 10\relax |
| 1152 |
\advance\tmpsetansctr -\tmpsetctr |
| 1153 |
\or % 5 |
| 1154 |
\divide\tmpsetansctr by 10000\relax |
| 1155 |
\tmpsetctr=\tmpsetansctr |
| 1156 |
\divide\tmpsetctr 10\relax \multiply\tmpsetctr 10\relax |
| 1157 |
\advance\tmpsetansctr -\tmpsetctr |
| 1158 |
\or % 6 |
| 1159 |
\divide\tmpsetansctr by 1000\relax |
| 1160 |
\tmpsetctr=\tmpsetansctr |
| 1161 |
\divide\tmpsetctr 10\relax \multiply\tmpsetctr 10\relax |
| 1162 |
\advance\tmpsetansctr -\tmpsetctr |
| 1163 |
\or % 7 |
| 1164 |
\divide\tmpsetansctr by 100\relax |
| 1165 |
\tmpsetctr=\tmpsetansctr |
| 1166 |
\divide\tmpsetctr 10\relax \multiply\tmpsetctr 10\relax |
| 1167 |
\advance\tmpsetansctr -\tmpsetctr |
| 1168 |
\or % 8 |
| 1169 |
\divide\tmpsetansctr by 10\relax |
| 1170 |
\tmpsetctr=\tmpsetansctr |
| 1171 |
\divide\tmpsetctr 10\relax \multiply\tmpsetctr 10\relax |
| 1172 |
\advance\tmpsetansctr -\tmpsetctr |
| 1173 |
\or % 9 |
| 1174 |
\tmpsetctr=\tmpsetansctr |
| 1175 |
\divide\tmpsetctr 10\relax \multiply\tmpsetctr 10\relax |
| 1176 |
\advance\tmpsetansctr -\tmpsetctr |
| 1177 |
\else % error |
| 1178 |
\tmpsetansctr=\z@ |
| 1179 |
\fi |
| 1180 |
\fi |
| 1181 |
#3=\tmpsetansctr} |
| 1182 |
|
| 1183 |
% \end{macrocode} |
| 1184 |
% \end{macro} |
| 1185 |
% |
| 1186 |
% \begin{macro}{\deletenumfromset} |
| 1187 |
% \cs{deletenumfromset}\marg{digit}\marg{set}\marg{cnt} removes the |
| 1188 |
% \meta{digit} from the \meta{set} and sets the \cs{count} \meta{cnt} |
| 1189 |
% to the reulting modified set. If \meta{digit} was the only member |
| 1190 |
% then the result is that digit negated. For example: \\ |
| 1191 |
% \verb?9? from \verb?[...11] -> [...10]? \\ |
| 1192 |
% \verb?8? from \verb?[0...010] -> -8? |
| 1193 |
% \begin{macrocode} |
| 1194 |
%%\deletenumfromset{digit}{set}{returnctr} |
| 1195 |
%% deletes num from the [set], returning the modified set or a -ve number if |
| 1196 |
%% the digit was the only member. |
| 1197 |
%% e.g., 9 from [...11] -> [...10], 8 from [0...010] -> -8 |
| 1198 |
\newcommand*{\deletenumfromset}[3]{ |
| 1199 |
\global\setchangedfalse |
| 1200 |
\tmpsetctr=#2\relax |
| 1201 |
\tmpsetansctr=#2\relax |
| 1202 |
\ifnum\tmpsetctr<\z@ % represents a solved number, do nothing |
| 1203 |
\else |
| 1204 |
\ifcase #1\relax |
| 1205 |
\or % 1 |
| 1206 |
\divide\tmpsetctr by 100000000\relax |
| 1207 |
\ifodd\tmpsetctr% it's there |
| 1208 |
\advance\tmpsetansctr -100000000\relax |
| 1209 |
\global\setchangedtrue |
| 1210 |
\fi |
| 1211 |
\or % 2 |
| 1212 |
\divide\tmpsetctr by 10000000\relax |
| 1213 |
\ifodd\tmpsetctr% it's there |
| 1214 |
\advance\tmpsetansctr -10000000\relax |
| 1215 |
\global\setchangedtrue |
| 1216 |
\fi |
| 1217 |
\or % 3 |
| 1218 |
\divide\tmpsetctr by 1000000\relax |
| 1219 |
\ifodd\tmpsetctr% it's there |
| 1220 |
\advance\tmpsetansctr -1000000\relax |
| 1221 |
\global\setchangedtrue |
| 1222 |
\fi |
| 1223 |
\or % 4 |
| 1224 |
\divide\tmpsetctr by 100000\relax |
| 1225 |
\ifodd\tmpsetctr% it's there |
| 1226 |
\advance\tmpsetansctr -100000\relax |
| 1227 |
\global\setchangedtrue |
| 1228 |
\fi |
| 1229 |
\or % 5 |
| 1230 |
\divide\tmpsetctr by 10000\relax |
| 1231 |
\ifodd\tmpsetctr% it's there |
| 1232 |
\advance\tmpsetansctr -10000\relax |
| 1233 |
\global\setchangedtrue |
| 1234 |
\fi |
| 1235 |
\or % 6 |
| 1236 |
\divide\tmpsetctr by 1000\relax |
| 1237 |
\ifodd\tmpsetctr% it's there |
| 1238 |
\advance\tmpsetansctr -1000\relax |
| 1239 |
\global\setchangedtrue |
| 1240 |
\fi |
| 1241 |
\or % 7 |
| 1242 |
\divide\tmpsetctr by 100\relax |
| 1243 |
\ifodd\tmpsetctr% it's there |
| 1244 |
\advance\tmpsetansctr -100\relax |
| 1245 |
\global\setchangedtrue |
| 1246 |
\fi |
| 1247 |
\or % 8 |
| 1248 |
\divide\tmpsetctr by 10\relax |
| 1249 |
\ifodd\tmpsetctr% it's there |
| 1250 |
\advance\tmpsetansctr -10\relax |
| 1251 |
\global\setchangedtrue |
| 1252 |
\fi |
| 1253 |
\or % 9 |
| 1254 |
\ifodd\tmpsetctr% it's there |
| 1255 |
\advance\tmpsetansctr -1\relax |
| 1256 |
\global\setchangedtrue |
| 1257 |
\fi |
| 1258 |
\fi |
| 1259 |
\fi |
| 1260 |
#3=\tmpsetansctr} |
| 1261 |
|
| 1262 |
% \end{macrocode} |
| 1263 |
% \end{macro} |
| 1264 |
% |
| 1265 |
% \begin{macro}{\displaystatus} |
| 1266 |
% This macro typesets a tabular showing the current real and potential |
| 1267 |
% solutions for the grid. A real solution is shown as a negative number; |
| 1268 |
% positive numbers are the potential solution digits for the cell. |
| 1269 |
% \begin{macrocode} |
| 1270 |
%% typeset current answers plus potential answer digits |
| 1271 |
\newcommand*{\displaystatus}{% |
| 1272 |
\begin{tabular}{||c|c|c||c|c|c||c|c|c||}\hline\hline |
| 1273 |
\settonum{\the\useknt{s@lans1}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1274 |
\settonum{\the\useknt{s@lans2}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1275 |
\settonum{\the\useknt{s@lans3}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1276 |
\settonum{\the\useknt{s@lans4}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1277 |
\settonum{\the\useknt{s@lans5}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1278 |
\settonum{\the\useknt{s@lans6}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1279 |
\settonum{\the\useknt{s@lans7}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1280 |
\settonum{\the\useknt{s@lans8}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1281 |
\settonum{\the\useknt{s@lans9}}{\s@dtempcnta}\the\s@dtempcnta \\ \hline |
| 1282 |
\settonum{\the\useknt{s@lans10}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1283 |
\settonum{\the\useknt{s@lans11}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1284 |
\settonum{\the\useknt{s@lans12}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1285 |
\settonum{\the\useknt{s@lans13}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1286 |
\settonum{\the\useknt{s@lans14}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1287 |
\settonum{\the\useknt{s@lans15}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1288 |
\settonum{\the\useknt{s@lans16}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1289 |
\settonum{\the\useknt{s@lans17}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1290 |
\settonum{\the\useknt{s@lans18}}{\s@dtempcnta}\the\s@dtempcnta \\ \hline |
| 1291 |
\settonum{\the\useknt{s@lans19}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1292 |
\settonum{\the\useknt{s@lans20}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1293 |
\settonum{\the\useknt{s@lans21}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1294 |
\settonum{\the\useknt{s@lans22}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1295 |
\settonum{\the\useknt{s@lans23}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1296 |
\settonum{\the\useknt{s@lans24}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1297 |
\settonum{\the\useknt{s@lans25}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1298 |
\settonum{\the\useknt{s@lans26}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1299 |
\settonum{\the\useknt{s@lans27}}{\s@dtempcnta}\the\s@dtempcnta \\ \hline\hline |
| 1300 |
\settonum{\the\useknt{s@lans28}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1301 |
\settonum{\the\useknt{s@lans29}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1302 |
\settonum{\the\useknt{s@lans30}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1303 |
\settonum{\the\useknt{s@lans31}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1304 |
\settonum{\the\useknt{s@lans32}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1305 |
\settonum{\the\useknt{s@lans33}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1306 |
\settonum{\the\useknt{s@lans34}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1307 |
\settonum{\the\useknt{s@lans35}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1308 |
\settonum{\the\useknt{s@lans36}}{\s@dtempcnta}\the\s@dtempcnta \\ \hline |
| 1309 |
\settonum{\the\useknt{s@lans37}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1310 |
\settonum{\the\useknt{s@lans38}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1311 |
\settonum{\the\useknt{s@lans39}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1312 |
\settonum{\the\useknt{s@lans40}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1313 |
\settonum{\the\useknt{s@lans41}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1314 |
\settonum{\the\useknt{s@lans42}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1315 |
\settonum{\the\useknt{s@lans43}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1316 |
\settonum{\the\useknt{s@lans44}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1317 |
\settonum{\the\useknt{s@lans45}}{\s@dtempcnta}\the\s@dtempcnta \\ \hline |
| 1318 |
\settonum{\the\useknt{s@lans46}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1319 |
\settonum{\the\useknt{s@lans47}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1320 |
\settonum{\the\useknt{s@lans48}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1321 |
\settonum{\the\useknt{s@lans49}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1322 |
\settonum{\the\useknt{s@lans50}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1323 |
\settonum{\the\useknt{s@lans51}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1324 |
\settonum{\the\useknt{s@lans52}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1325 |
\settonum{\the\useknt{s@lans53}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1326 |
\settonum{\the\useknt{s@lans54}}{\s@dtempcnta}\the\s@dtempcnta \\ \hline\hline |
| 1327 |
\settonum{\the\useknt{s@lans55}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1328 |
\settonum{\the\useknt{s@lans56}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1329 |
\settonum{\the\useknt{s@lans57}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1330 |
\settonum{\the\useknt{s@lans58}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1331 |
\settonum{\the\useknt{s@lans59}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1332 |
\settonum{\the\useknt{s@lans60}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1333 |
\settonum{\the\useknt{s@lans61}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1334 |
\settonum{\the\useknt{s@lans62}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1335 |
\settonum{\the\useknt{s@lans63}}{\s@dtempcnta}\the\s@dtempcnta \\ \hline |
| 1336 |
\settonum{\the\useknt{s@lans64}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1337 |
\settonum{\the\useknt{s@lans65}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1338 |
\settonum{\the\useknt{s@lans66}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1339 |
\settonum{\the\useknt{s@lans67}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1340 |
\settonum{\the\useknt{s@lans68}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1341 |
\settonum{\the\useknt{s@lans69}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1342 |
\settonum{\the\useknt{s@lans70}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1343 |
\settonum{\the\useknt{s@lans71}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1344 |
\settonum{\the\useknt{s@lans72}}{\s@dtempcnta}\the\s@dtempcnta \\ \hline |
| 1345 |
\settonum{\the\useknt{s@lans73}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1346 |
\settonum{\the\useknt{s@lans74}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1347 |
\settonum{\the\useknt{s@lans75}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1348 |
\settonum{\the\useknt{s@lans76}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1349 |
\settonum{\the\useknt{s@lans77}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1350 |
\settonum{\the\useknt{s@lans78}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1351 |
\settonum{\the\useknt{s@lans79}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1352 |
\settonum{\the\useknt{s@lans80}}{\s@dtempcnta}\the\s@dtempcnta & |
| 1353 |
\settonum{\the\useknt{s@lans81}}{\s@dtempcnta}\the\s@dtempcnta \\ \hline\hline |
| 1354 |
\end{tabular}} |
| 1355 |
|
| 1356 |
% \end{macrocode} |
| 1357 |
% \end{macro} |
| 1358 |
% |
| 1359 |
% \subsubsection{Problem initialisation} |
| 1360 |
% |
| 1361 |
% \begin{macrocode} |
| 1362 |
%%%%%%%%%%%%%%%%%%%% get the problem and initialise the solution %%%%%%%%% |
| 1363 |
|
| 1364 |
% \end{macrocode} |
| 1365 |
% |
| 1366 |
% \begin{macro}{\getproblem} |
| 1367 |
% \cs{getproblem}\marg{file} initialises the solution grid and reads the |
| 1368 |
% puzzle from the sudoku file \meta{file}. It calls \cs{initialsoln} |
| 1369 |
% to read the file and insert the clues into the grid. |
| 1370 |
% \begin{macrocode} |
| 1371 |
%% read the problem and initialise the problem (solution) |
| 1372 |
\newcommand*{\getproblem}[1]{\bgroup |
| 1373 |
\initialisesuddata |
| 1374 |
\global\solcnt\z@ |
| 1375 |
\immediate\closein\s@dread |
| 1376 |
\immediate\openin\s@dread=#1 |
| 1377 |
\initialsoln |
| 1378 |
\typeout{Sudoku problem #1, \the\solcnt\space initial clues} |
| 1379 |
\egroup} |
| 1380 |
|
| 1381 |
% \end{macrocode} |
| 1382 |
% \end{macro} |
| 1383 |
% |
| 1384 |
% \begin{macro}{\initialsoln} |
| 1385 |
% Get the clues from the puzzle file, line by line, and insert them into |
| 1386 |
% the grid. \cs{s@dline} holds one line from the file. |
| 1387 |
% \begin{macrocode} |
| 1388 |
%% insert the clues from the input game file |
| 1389 |
\newcommand*{\initialsoln}{% |
| 1390 |
\firsts@dcluetrue |
| 1391 |
\s@dnrow\@ne |
| 1392 |
\s@lcnta\@ne |
| 1393 |
\loop |
| 1394 |
\ifnum\s@dnrow<10\relax |
| 1395 |
\read\s@dread to \s@dline |
| 1396 |
\firsts@dcluetrue |
| 1397 |
\s@dncol\@ne |
| 1398 |
\dos@dinitialcols |
| 1399 |
\advance\s@dnrow\@ne |
| 1400 |
\repeat |
| 1401 |
\immediate\closein\s@dread} |
| 1402 |
|
| 1403 |
% \end{macrocode} |
| 1404 |
% \end{macro} |
| 1405 |
% |
| 1406 |
% \begin{macro}{\dos@dinitialcols} |
| 1407 |
% Insert the clues from one line of the puzzle file into one row of the grid. |
| 1408 |
% \begin{macrocode} |
| 1409 |
%% insert the clues from one line of the game file |
| 1410 |
\newcommand*{\dos@dinitialcols}{\bgroup |
| 1411 |
\loop |
| 1412 |
\ifnum\s@dncol<10\relax |
| 1413 |
\fixentry |
| 1414 |
\advance\s@dncol\@ne |
| 1415 |
\repeat |
| 1416 |
\egroup} |
| 1417 |
|
| 1418 |
% \end{macrocode} |
| 1419 |
% \end{macro} |
| 1420 |
% |
| 1421 |
% \begin{macro}{\fixentry} |
| 1422 |
% Inserts a clue from the current line into the grid. |
| 1423 |
% \begin{macrocode} |
| 1424 |
%% insert a clue from the current line of the game file |
| 1425 |
\newcommand*{\fixentry}{% |
| 1426 |
\iffirsts@dclue |
| 1427 |
\expandafter\splitoff\expandafter{\s@dline}% |
| 1428 |
\global\firsts@dcluefalse |
| 1429 |
\else |
| 1430 |
\expandafter\splitoff\expandafter{\restchars}% |
| 1431 |
\fi |
| 1432 |
\ifx\s@dfstop\istchar |
| 1433 |
\else |
| 1434 |
\global\useknt{s@lans\the\s@lcnta}=-\istchar |
| 1435 |
\global\advance\solcnt\@ne |
| 1436 |
\global\advance\numcluesctr\@ne |
| 1437 |
\fi |
| 1438 |
\global\advance\s@lcnta\@ne} |
| 1439 |
|
| 1440 |
|
| 1441 |
% \end{macrocode} |
| 1442 |
% \end{macro} |
| 1443 |
% |
| 1444 |
% \subsection{Solution methods} |
| 1445 |
% |
| 1446 |
% |
| 1447 |
% Three facts are used to generate a solution. |
| 1448 |
% \begin{enumerate} |
| 1449 |
% \item A digit must be unique within a row, a column, and a block |
| 1450 |
% Thus, if a solution, say N, is known for a cell, then the |
| 1451 |
% potential solution N must be deleted from all cells in the |
| 1452 |
% row, column, and block that the solved cell is in. I have |
| 1453 |
% called this a simple reduction. The simple reductions are repeated |
| 1454 |
% until there are no changes to the potential solutions. |
| 1455 |
% |
| 1456 |
% \item If among all the cells in a row (column, block) there is a digit |
| 1457 |
% that occurs only once among all the potential solutions, then that |
| 1458 |
% digit is the solution for its cell. I have termed this a loner. |
| 1459 |
% If a loner solution is found then simple reductions are repeated. |
| 1460 |
% |
| 1461 |
% \item If among all the cells in a row (column, block) there are two digits |
| 1462 |
% which occur twice only in the row, each time as a pair (e.g., 39 |
| 1463 |
% and 39) then one or other of the two digits must be a solution for |
| 1464 |
% a cell in which the pairs occur. This means that the two digits in |
| 1465 |
% the pair cannot occur anywhere else in the row (column, block). |
| 1466 |
% If there are no loners then the problem is examined for pairs. If |
| 1467 |
% there is any change in a potential solution then the simple |
| 1468 |
% reduction process is applied. |
| 1469 |
% \end{enumerate} |
| 1470 |
% |
| 1471 |
% The process stops either when all 81 cells have been solved or there |
| 1472 |
% is no change in any potential solution after going through all the above |
| 1473 |
% reductions. |
| 1474 |
% |
| 1475 |
% There are more sophisticated solution techniques that could be applied |
| 1476 |
% but they are also increasingly difficult to code in \TeX. |
| 1477 |
% |
| 1478 |
% \begin{macro}{\reduceacell} |
| 1479 |
% \cs{reduceacell} looks at the solution set for the current cell (the |
| 1480 |
% \cs{s@lcnta} cell) and if the cell has been solved then it deletes the |
| 1481 |
% solution digit from the row, column, and box in which the cell appears. |
| 1482 |
% This may result in new solutions for other cells. |
| 1483 |
% |
| 1484 |
% Given a cell number $N$ ($0<N<82$) and, using integer arithmetic, |
| 1485 |
% putting $M = (N-1)/9$ then |
| 1486 |
% \begin{itemize} |
| 1487 |
% \item Cell number $C$ at top of column: $C = N - 9M$ |
| 1488 |
% \item Cell number $R$ at left of row: $R = 9M + 1$ |
| 1489 |
% \item Cell number $b$ at top left of 3 by 3 box: |
| 1490 |
% $B = 27(M/3) + 3((N-1-9M)/3) + 1$ |
| 1491 |
% \end{itemize} |
| 1492 |
% |
| 1493 |
% \begin{macrocode} |
| 1494 |
%% Eliminate a solution digit from its row, column and box. |
| 1495 |
%% This may result in some new solutions. |
| 1496 |
\newcommand*{\reduceacell}{\bgroup |
| 1497 |
\ifnum\useknt{s@lans\the\s@lcnta}<\z@ % solved cell |
| 1498 |
\s@dtempcnta=-\useknt{s@lans\the\s@lcnta} |
| 1499 |
%% get the col, row and box numbers |
| 1500 |
\tempcnty=\s@lcnta % M in the formulae |
| 1501 |
\advance\tempcnty\m@ne \divide\tempcnty 9\relax |
| 1502 |
\tempcntz=\tempcnty \multiply\tempcntz 9\relax |
| 1503 |
\s@dcolpos=\s@lcnta \advance\s@dcolpos -\tempcntz % col |
| 1504 |
\s@drowpos\tempcntz \advance\s@drowpos\@ne % row |
| 1505 |
\boxctr=\tempcnty % box |
| 1506 |
\divide\boxctr\thr@@ \multiply\boxctr 27\relax |
| 1507 |
\tempcnty=\s@lcnta % reuse \tempcnty |
| 1508 |
\advance\tempcnty\m@ne \advance\tempcnty -\tempcntz |
| 1509 |
\divide\tempcnty\thr@@ \multiply\tempcnty \thr@@ |
| 1510 |
\advance\boxctr\tempcnty \advance\boxctr \@ne |
| 1511 |
%% reduce the row, column, and the box |
| 1512 |
\reducerow{\the\s@drowpos}{\the\s@dtempcnta} |
| 1513 |
\reducecol{\the\s@dcolpos}{\the\s@dtempcnta} |
| 1514 |
\reducebox{\the\boxctr}{\the\s@dtempcnta} |
| 1515 |
\fi |
| 1516 |
\egroup} |
| 1517 |
|
| 1518 |
% \end{macrocode} |
| 1519 |
% \end{macro} |
| 1520 |
% |
| 1521 |
% \begin{macro}{\reducerow} |
| 1522 |
% \cs{reducerow}\marg{row}\marg{digit} eliminates \meta{digit} from the |
| 1523 |
% binary solution sets of the cells in the row starting at cell number |
| 1524 |
% \meta{row}. |
| 1525 |
% \begin{macrocode} |
| 1526 |
%% \reducerow{rowcellnumber}{digit} |
| 1527 |
%% simple reduction for digit in a row |
| 1528 |
\newcommand*{\reducerow}[2]{\bgroup |
| 1529 |
\s@dncol=#1\relax |
| 1530 |
\toprangectr=\s@dncol |
| 1531 |
\advance\toprangectr 9\relax |
| 1532 |
\bgroup |
| 1533 |
\loop |
| 1534 |
\ifnum\s@dncol<\toprangectr |
| 1535 |
\deletenumfromset{#2}{\the\useknt{s@lans\the\s@dncol}}{\reducedctr} |
| 1536 |
\ifsetchanged |
| 1537 |
\global\changedtrue |
| 1538 |
\settonum{\the\reducedctr}{\numlistctr} |
| 1539 |
\ifnum\numlistctr<10\relax |
| 1540 |
\global\advance\solcnt\@ne |
| 1541 |
\commentary{\the\solcnt\space solved |
| 1542 |
(\the\s@dncol\space = \the\numlistctr\space in row starting #1)}% |
| 1543 |
\global\useknt{s@lans\the\s@dncol}=\numlistctr |
| 1544 |
\else |
| 1545 |
\global\useknt{s@lans\the\s@dncol}=\reducedctr |
| 1546 |
\fi |
| 1547 |
\fi |
| 1548 |
\advance\s@dncol\@ne |
| 1549 |
\repeat |
| 1550 |
\egroup |
| 1551 |
\egroup} |
| 1552 |
|
| 1553 |
% \end{macrocode} |
| 1554 |
% \end{macro} |
| 1555 |
% |
| 1556 |
% \begin{macro}{\reducecol} |
| 1557 |
% \cs{reducecol}\marg{col}\marg{digit} eliminates \meta{digit} from the |
| 1558 |
% binary solution sets of the cells in the column starting at cell number |
| 1559 |
% \meta{col}. |
| 1560 |
% \begin{macrocode} |
| 1561 |
%% \reducecol{colcellnumber}{digit} |
| 1562 |
%% simple reduction of a digit in a column |
| 1563 |
\newcommand*{\reducecol}[2]{\bgroup |
| 1564 |
\s@dnrow=#1\relax |
| 1565 |
\toprangectr=\s@dnrow |
| 1566 |
\advance\toprangectr 73\relax |
| 1567 |
\bgroup |
| 1568 |
\loop |
| 1569 |
\ifnum\s@dnrow<\toprangectr |
| 1570 |
\deletenumfromset{#2}{\the\useknt{s@lans\the\s@dnrow}}{\reducedctr} |
| 1571 |
\ifsetchanged |
| 1572 |
\global\changedtrue |
| 1573 |
\settonum{\the\reducedctr}{\numlistctr} |
| 1574 |
\ifnum\numlistctr<10\relax |
| 1575 |
\global\advance\solcnt\@ne |
| 1576 |
\commentary{\the\solcnt\space solved |
| 1577 |
(\the\s@dnrow\space = \the\numlistctr\space in column starting #1)}% |
| 1578 |
\global\useknt{s@lans\the\s@dnrow}=\numlistctr |
| 1579 |
\else |
| 1580 |
\global\useknt{s@lans\the\s@dnrow}=\reducedctr |
| 1581 |
\fi |
| 1582 |
\fi |
| 1583 |
\advance\s@dnrow 9\relax |
| 1584 |
\repeat |
| 1585 |
\egroup |
| 1586 |
\egroup} |
| 1587 |
|
| 1588 |
% \end{macrocode} |
| 1589 |
% \end{macro} |
| 1590 |
% |
| 1591 |
% \begin{macro}{\reducebox} |
| 1592 |
% \cs{reducebox}\marg{box}\marg{digit} eliminates \meta{digit} from the |
| 1593 |
% binary solution sets of the cells in the box starting at cell number |
| 1594 |
% \meta{box}. |
| 1595 |
% \begin{macrocode} |
| 1596 |
%% \reducebox{boxcellnumber}{digit} |
| 1597 |
%% simple reduction of a digit in a box |
| 1598 |
\newcommand*{\reducebox}[2]{\bgroup |
| 1599 |
\s@dncol=#1\relax |
| 1600 |
\toprangectr=\s@dncol |
| 1601 |
\advance\toprangectr \thr@@ |
| 1602 |
\bgroup |
| 1603 |
\loop |
| 1604 |
\ifnum\s@dncol<\toprangectr |
| 1605 |
\s@dnrow=\s@dncol |
| 1606 |
\deletenumfromset{#2}{\the\useknt{s@lans\the\s@dnrow}}{\reducedctr} |
| 1607 |
\ifsetchanged |
| 1608 |
\global\changedtrue |
| 1609 |
\settonum{\the\reducedctr}{\numlistctr} |
| 1610 |
\ifnum\numlistctr<10\relax |
| 1611 |
\global\advance\solcnt\@ne |
| 1612 |
\commentary{\the\solcnt\space solved |
| 1613 |
(\the\s@dnrow\space = \the\numlistctr\space in box starting #1)}% |
| 1614 |
\global\useknt{s@lans\the\s@dnrow}=\numlistctr |
| 1615 |
\else |
| 1616 |
\global\useknt{s@lans\the\s@dnrow}=\reducedctr |
| 1617 |
\fi |
| 1618 |
\fi |
| 1619 |
\advance\s@dnrow 9\relax |
| 1620 |
\deletenumfromset{#2}{\the\useknt{s@lans\the\s@dnrow}}{\reducedctr} |
| 1621 |
\ifsetchanged |
| 1622 |
\global\changedtrue |
| 1623 |
\settonum{\the\reducedctr}{\numlistctr} |
| 1624 |
\ifnum\numlistctr<10\relax |
| 1625 |
\global\advance\solcnt\@ne |
| 1626 |
\commentary{\the\solcnt\space solved |
| 1627 |
(\the\s@dnrow\space = \the\numlistctr\space in box starting #1)}% |
| 1628 |
\global\useknt{s@lans\the\s@dnrow}=\numlistctr |
| 1629 |
\else |
| 1630 |
\global\useknt{s@lans\the\s@dnrow}=\reducedctr |
| 1631 |
\fi |
| 1632 |
\fi |
| 1633 |
\advance\s@dnrow 9\relax |
| 1634 |
\deletenumfromset{#2}{\the\useknt{s@lans\the\s@dnrow}}{\reducedctr} |
| 1635 |
\ifsetchanged |
| 1636 |
\global\changedtrue |
| 1637 |
\settonum{\the\reducedctr}{\numlistctr} |
| 1638 |
\ifnum\numlistctr<10\relax |
| 1639 |
\global\advance\solcnt\@ne |
| 1640 |
\commentary{\the\solcnt\space solved |
| 1641 |
(\the\s@dnrow\space = \the\numlistctr\space in box starting #1)}% |
| 1642 |
\global\useknt{s@lans\the\s@dnrow}=\numlistctr |
| 1643 |
\else |
| 1644 |
\global\useknt{s@lans\the\s@dnrow}=\reducedctr |
| 1645 |
\fi |
| 1646 |
\fi |
| 1647 |
\advance\s@dncol \@ne |
| 1648 |
\repeat |
| 1649 |
\egroup |
| 1650 |
\egroup} |
| 1651 |
|
| 1652 |
% \end{macrocode} |
| 1653 |
% \end{macro} |
| 1654 |
% |
| 1655 |
% \begin{macro}{\reduceallcells} |
| 1656 |
% \cs{reduceallcells} examines all 81 cells, eliminating solution digits |
| 1657 |
% from the binary solution sets of the other cells in the row, column, and box. |
| 1658 |
% \begin{macrocode} |
| 1659 |
%% loop over every cell, removing solution digits from the potential sets |
| 1660 |
%% in the cell's row, column and box. |
| 1661 |
\newcommand*{\reduceallcells}{\bgroup |
| 1662 |
\ifnum\difficultyctr<\@ne |
| 1663 |
\global\difficultyctr\@ne |
| 1664 |
\fi |
| 1665 |
\s@lcnta\@ne |
| 1666 |
\global\changedfalse |
| 1667 |
\loop |
| 1668 |
\ifnum\s@lcnta<82\relax |
| 1669 |
\reduceacell |
| 1670 |
\advance\s@lcnta\@ne |
| 1671 |
\repeat |
| 1672 |
\egroup} |
| 1673 |
|
| 1674 |
% \end{macrocode} |
| 1675 |
% \end{macro} |
| 1676 |
% |
| 1677 |
% \begin{macro}{\keepreducing} |
| 1678 |
% \cs{keepreducing} performs simple reductions on all the cells until either |
| 1679 |
% the puzzle is solved or no changes have been made. It then tries loner |
| 1680 |
% reductions, returning to simple reductions following any change. If |
| 1681 |
% no change has been made after loner reductions it then tries pair reductions. |
| 1682 |
% After any change it goes back to simple reductions. This iterative process |
| 1683 |
% continues until either the puzzle has been solved (\cs{solcnt} = 81) |
| 1684 |
% or no further changes can be made. |
| 1685 |
% |
| 1686 |
% A measure of the difficulty of the puzzle could be made by incrementing a |
| 1687 |
% count |
| 1688 |
% each time a new kind of reduction is tried. The increment increases with |
| 1689 |
% the complexity of the reduction. |
| 1690 |
% |
| 1691 |
% \begin{macrocode} |
| 1692 |
\newcommand*{\keepreducing}{% |
| 1693 |
\anychangetrue |
| 1694 |
\keepontrue |
| 1695 |
\loop |
| 1696 |
\ifkeepon |
| 1697 |
\keepreducingcells |
| 1698 |
\ifnum\solcnt<81\relax |
| 1699 |
%%% \advance\difficultyctr 4\relax |
| 1700 |
\reduceloners |
| 1701 |
\fi |
| 1702 |
\anychangefalse |
| 1703 |
\iflonerchanged |
| 1704 |
\anychangetrue |
| 1705 |
\fi |
| 1706 |
\ifanychange\else |
| 1707 |
\ifnum\solcnt<81\relax |
| 1708 |
%%% \advance\difficultyctr 8\relax |
| 1709 |
\pairchangedfalse |
| 1710 |
\reducepairs |
| 1711 |
\ifpairchanged |
| 1712 |
\anychangetrue |
| 1713 |
\fi |
| 1714 |
\fi |
| 1715 |
\fi |
| 1716 |
\checkkeepon |
| 1717 |
\repeat |
| 1718 |
\ifnum\solcnt<81\relax |
| 1719 |
\global\multiply \difficultyctr 10\relax |
| 1720 |
\fi |
| 1721 |
\typeout{************ Number of solutions = \the\solcnt} |
| 1722 |
\typeout{************ Difficulty rating = \the\difficultyctr} |
| 1723 |
} |
| 1724 |
|
| 1725 |
% \end{macrocode} |
| 1726 |
% \end{macro} |
| 1727 |
% |
| 1728 |
% \begin{macro}{\checkkeepon} |
| 1729 |
% Determines whether or not to keep on trying to reach the solution. |
| 1730 |
% \begin{macrocode} |
| 1731 |
\newcommand*{\checkkeepon}{% |
| 1732 |
\ifnum\solcnt>80\relax |
| 1733 |
\keeponfalse |
| 1734 |
\fi |
| 1735 |
\ifanychange\else |
| 1736 |
\keeponfalse |
| 1737 |
\fi} |
| 1738 |
|
| 1739 |
% \end{macrocode} |
| 1740 |
% \end{macro} |
| 1741 |
% |
| 1742 |
% \begin{macro}{\keepreducingcells} |
| 1743 |
% Keep on trying the simple reduction. |
| 1744 |
% \begin{macrocode} |
| 1745 |
%% Keep performing the simple reduction |
| 1746 |
\newcommand*{\keepreducingcells}{\bgroup |
| 1747 |
\commentary{Simple reductions}% |
| 1748 |
\ifnum\difficultyctr<\tw@ |
| 1749 |
\global\difficultyctr\tw@ |
| 1750 |
\fi |
| 1751 |
\changedtrue |
| 1752 |
\loop |
| 1753 |
\ifchanged |
| 1754 |
\reduceallcells |
| 1755 |
\checksimplereductions |
| 1756 |
\repeat |
| 1757 |
\egroup} |
| 1758 |
|
| 1759 |
% \end{macrocode} |
| 1760 |
% \end{macro} |
| 1761 |
% |
| 1762 |
% \begin{macro}{\checksimplereductions} |
| 1763 |
% Determines whether or not to keep on trying simple reductions. |
| 1764 |
% \begin{macrocode} |
| 1765 |
\newcommand*{\checksimplereductions}{% |
| 1766 |
\ifchanged\else |
| 1767 |
\typesimplestatus |
| 1768 |
\fi |
| 1769 |
\ifnum\solcnt>80\relax% solution found! |
| 1770 |
\changedfalse |
| 1771 |
\fi} |
| 1772 |
|
| 1773 |
% \end{macrocode} |
| 1774 |
% \end{macro} |
| 1775 |
% |
| 1776 |
% \begin{macrocode} |
| 1777 |
%%%%%%%%%%%%%%%%%%%%% reduce loners %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1778 |
|
| 1779 |
% \end{macrocode} |
| 1780 |
% |
| 1781 |
% \begin{macro}{\reduceloners} |
| 1782 |
% Reduce via the loner digits, trying rows first, and if no change |
| 1783 |
% then trying columns, and if still no change then trying boxes. |
| 1784 |
% \begin{macrocode} |
| 1785 |
%% reduce the loner digits, per row, column and box |
| 1786 |
\newcommand*{\reduceloners}{% |
| 1787 |
\commentary{reduceloners}% |
| 1788 |
\global\lonerchangedfalse |
| 1789 |
\ifnum\difficultyctr<4\relax |
| 1790 |
\global\difficultyctr=4\relax |
| 1791 |
\fi |
| 1792 |
\ifnum\solcnt>80\else |
| 1793 |
\bgroup |
| 1794 |
\reducerowloners |
| 1795 |
\iflonerchanged\else |
| 1796 |
\reducecolloners |
| 1797 |
\iflonerchanged\else |
| 1798 |
\reduceboxloners |
| 1799 |
\fi |
| 1800 |
\fi |
| 1801 |
\typelonestatus |
| 1802 |
\egroup |
| 1803 |
\fi} |
| 1804 |
|
| 1805 |
% \end{macrocode} |
| 1806 |
% \end{macro} |
| 1807 |
% |
| 1808 |
% \begin{macro}{\reducerowloners} |
| 1809 |
% Loop through the rows and reduce the first loner found. |
| 1810 |
% \begin{macrocode} |
| 1811 |
%% Loop through the rows, reducing loners |
| 1812 |
\newcommand*{\reducerowloners}{% |
| 1813 |
\sumctr\z@ |
| 1814 |
\s@dnrow\@ne |
| 1815 |
\loop |
| 1816 |
\ifnum\s@dnrow<10\relax |
| 1817 |
\s@lcnta=\s@dnrow \advance\s@lcnta\m@ne |
| 1818 |
\multiply\s@lcnta 9\relax \advance\s@lcnta\@ne |
| 1819 |
\sumrowsets |
| 1820 |
\ifnum\sumctr>\z@ |
| 1821 |
\getloner{\the\sumctr}{\s@dtempcntb} |
| 1822 |
\ifnum\s@dtempcntb=\z@ |
| 1823 |
\else |
| 1824 |
\reducelonerrowcell{\the\s@lcnta}{\the\s@dtempcntb} |
| 1825 |
\iflonerchanged |
| 1826 |
\advance\s@dnrow 10\relax |
| 1827 |
\fi |
| 1828 |
\fi |
| 1829 |
\fi |
| 1830 |
\advance\s@dnrow\@ne |
| 1831 |
\repeat} |
| 1832 |
|
| 1833 |
% \end{macrocode} |
| 1834 |
% \end{macro} |
| 1835 |
% |
| 1836 |
% \begin{macro}{\sumrowsets} |
| 1837 |
% Add together all the solution binary sets for the unsolved cells |
| 1838 |
% in the current row (\cs{s@lcnta}). The result is in \cs{sumctr}. |
| 1839 |
% \begin{macrocode} |
| 1840 |
%% add the sets in the current row |
| 1841 |
\newcommand*{\sumrowsets}{% |
| 1842 |
\bgroup |
| 1843 |
\s@dncol=\s@lcnta |
| 1844 |
\toprangectr=\s@dncol |
| 1845 |
\advance\toprangectr 9\relax |
| 1846 |
\global\sumctr\z@ |
| 1847 |
\loop |
| 1848 |
\ifnum\s@dncol<\toprangectr |
| 1849 |
\ifnum\useknt{s@lans\the\s@dncol}>\z@ |
| 1850 |
\global\advance\sumctr\useknt{s@lans\the\s@dncol} |
| 1851 |
\fi |
| 1852 |
\advance\s@dncol\@ne |
| 1853 |
\repeat |
| 1854 |
\egroup} |
| 1855 |
|
| 1856 |
% \end{macrocode} |
| 1857 |
% \end{macro} |
| 1858 |
% |
| 1859 |
% \begin{macro}{\getloner} |
| 1860 |
% \cs{getloner}\marg{setsum}\marg{cnt} examines (the sum of) a solution set |
| 1861 |
% and returns the first loner (i.e., the first occurrence of the digit 1), or |
| 1862 |
% zero if there is none. The result is converted to a solution digit and |
| 1863 |
% assigned to the \cs{count} \meta{cnt}. |
| 1864 |
% |
| 1865 |
% For example, given the set \verb?[000200110]? it will return \verb?7? (the |
| 1866 |
% set indicates two 4s, one 7, and one 8). |
| 1867 |
% \begin{macrocode} |
| 1868 |
%% get the loner from a setsum |
| 1869 |
%% \getloner{setsum}{returnctr} returnes the (first) loner in a potential set, |
| 1870 |
%% or zero |
| 1871 |
\newcommand*{\getloner}[2]{\bgroup |
| 1872 |
\ifnum #1>\z@ |
| 1873 |
\s@dtemploopcnta\@ne |
| 1874 |
\loop |
| 1875 |
\ifnum\s@dtemploopcnta<10\relax |
| 1876 |
\numofnuminset{\the\s@dtemploopcnta}{#1}{\s@dtempcnta} |
| 1877 |
\ifnum\s@dtempcnta=\@ne% found a lone digit |
| 1878 |
\s@dtempcnta=\s@dtemploopcnta |
| 1879 |
\s@dtemploopcnta=100\relax |
| 1880 |
\fi |
| 1881 |
\advance\s@dtemploopcnta\@ne |
| 1882 |
\repeat |
| 1883 |
\ifnum\s@dtemploopcnta>99 \else \s@dtempcnta=\z@ \fi |
| 1884 |
\global#2=\s@dtempcnta |
| 1885 |
\else |
| 1886 |
\s@dtempcnta=\z@ |
| 1887 |
\global#2=\s@dtempcnta |
| 1888 |
\fi |
| 1889 |
\egroup} |
| 1890 |
|
| 1891 |
% \end{macrocode} |
| 1892 |
% \end{macro} |
| 1893 |
% |
| 1894 |
% \begin{macro}{\reducelonerowcell} |
| 1895 |
% \cs{reducelonerowcell}\marg{rowcell}\marg{digit}. |
| 1896 |
% Given (the cell at) the start of a row and a lone digit, find the cell |
| 1897 |
% in the row with that digit in its solution set, and make the digit the |
| 1898 |
% solution of that cell. |
| 1899 |
% \begin{macrocode} |
| 1900 |
%% \reducelonerowcell{startofrowcell}{digit} |
| 1901 |
%% given a row and a lone digit, find the cell containing the digit |
| 1902 |
%% and make the digit a solution of that cell. |
| 1903 |
\newcommand*{\reducelonerrowcell}[2]{\bgroup |
| 1904 |
\s@dncol=#1 |
| 1905 |
\toprangectr=\s@dncol |
| 1906 |
\advance\toprangectr 9\relax |
| 1907 |
\ifnum #2<\@ne |
| 1908 |
\advance\s@dncol 100\relax |
| 1909 |
\fi |
| 1910 |
\loop |
| 1911 |
\ifnum\s@dncol<\toprangectr |
| 1912 |
\numofnuminset{#2}{\the\useknt{s@lans\the\s@dncol}}{\lonecellctr} |
| 1913 |
\ifnum\lonecellctr=\@ne% this cell has the loner |
| 1914 |
\lonecellctr=#2 |
| 1915 |
\global\useknt{s@lans\the\s@dncol}=-\lonecellctr |
| 1916 |
\global\lonerchangedtrue |
| 1917 |
\global\advance\solcnt\@ne |
| 1918 |
\commentary{\the\solcnt\space solved (#2 loner in row starting #1)}% |
| 1919 |
\s@dncol=\toprangectr |
| 1920 |
\fi |
| 1921 |
\advance\s@dncol\@ne |
| 1922 |
\repeat |
| 1923 |
\egroup} |
| 1924 |
|
| 1925 |
% \end{macrocode} |
| 1926 |
% \end{macro} |
| 1927 |
% |
| 1928 |
% \begin{macro}{\reducecolloners} |
| 1929 |
% Loop through the columns and reduce the first loner found. |
| 1930 |
% \begin{macrocode} |
| 1931 |
%% Loop through the columns, reducing loners |
| 1932 |
\newcommand*{\reducecolloners}{\bgroup |
| 1933 |
\sumctr\z@ |
| 1934 |
\s@dncol\@ne |
| 1935 |
\loop |
| 1936 |
\ifnum\s@dncol<10\relax |
| 1937 |
\s@lcnta=\s@dncol |
| 1938 |
\sumcolsets |
| 1939 |
\ifnum\sumctr>\z@ |
| 1940 |
\getloner{\the\sumctr}{\s@dtempcntb} |
| 1941 |
\ifnum\s@dtempcntb=\z@ |
| 1942 |
\else |
| 1943 |
\reducelonercolcell{\the\s@lcnta}{\the\s@dtempcntb} |
| 1944 |
\iflonerchanged |
| 1945 |
\advance\s@dncol 10\relax |
| 1946 |
\fi |
| 1947 |
\fi |
| 1948 |
\fi |
| 1949 |
\advance\s@dncol\@ne |
| 1950 |
\repeat |
| 1951 |
\egroup} |
| 1952 |
|
| 1953 |
% \end{macrocode} |
| 1954 |
% \end{macro} |
| 1955 |
% |
| 1956 |
% \begin{macro}{\sumcolsets} |
| 1957 |
% Sum all the solution sets of the unsolved cells in the current column |
| 1958 |
% (\cs{s@lcnta}). The result is in \cs{sumctr}. |
| 1959 |
% \begin{macrocode} |
| 1960 |
%% add the sets in the current column |
| 1961 |
\newcommand*{\sumcolsets}{\bgroup |
| 1962 |
\s@dnrow=\s@lcnta |
| 1963 |
\toprangectr=\s@dnrow |
| 1964 |
\advance\toprangectr 73\relax |
| 1965 |
\global\sumctr\z@ |
| 1966 |
\loop |
| 1967 |
\ifnum\s@dnrow<\toprangectr |
| 1968 |
\ifnum\useknt{s@lans\the\s@dnrow}>\z@ |
| 1969 |
\global\advance\sumctr\useknt{s@lans\the\s@dnrow} |
| 1970 |
\fi |
| 1971 |
\advance\s@dnrow 9\relax |
| 1972 |
\repeat |
| 1973 |
\egroup} |
| 1974 |
|
| 1975 |
% \end{macrocode} |
| 1976 |
% \end{macro} |
| 1977 |
% |
| 1978 |
% \begin{macro}{\reducelonercolcell} |
| 1979 |
% \cs{reducelonercolcell}\marg{colcell}\marg{digit}. |
| 1980 |
% Given (the cell at) the start of a column and a lone digit, find the cell |
| 1981 |
% in the column with that digit in its solution set, and make the digit |
| 1982 |
% the solution of that cell. |
| 1983 |
% \begin{macrocode} |
| 1984 |
%% \reducelonercolcell{startofcolcell}{digit} |
| 1985 |
%% given a col and a lone digit, find the cell containing the digit |
| 1986 |
%% and make the digit a solution of that cell. |
| 1987 |
\newcommand*{\reducelonercolcell}[2]{\bgroup |
| 1988 |
\s@dnrow=#1 |
| 1989 |
\toprangectr=\s@dnrow |
| 1990 |
\advance\toprangectr 73\relax |
| 1991 |
\ifnum #2<\@ne |
| 1992 |
\advance\s@dnrow 7300\relax |
| 1993 |
\fi |
| 1994 |
\loop |
| 1995 |
\ifnum\s@dnrow<\toprangectr |
| 1996 |
\numofnuminset{#2}{\the\useknt{s@lans\the\s@dnrow}}{\lonecellctr} |
| 1997 |
\ifnum\lonecellctr=\@ne% this cell has the loner |
| 1998 |
\lonecellctr=#2 |
| 1999 |
\global\useknt{s@lans\the\s@dnrow}=-\lonecellctr |
| 2000 |
\global\lonerchangedtrue |
| 2001 |
\global\advance\solcnt\@ne |
| 2002 |
\commentary{\the\solcnt\space solved (#2 loner in column starting #1)}% |
| 2003 |
\s@dnrow=\toprangectr |
| 2004 |
\fi |
| 2005 |
\advance\s@dnrow 9\relax |
| 2006 |
\repeat |
| 2007 |
\egroup} |
| 2008 |
|
| 2009 |
% \end{macrocode} |
| 2010 |
% \end{macro} |
| 2011 |
% |
| 2012 |
% \begin{macro}{\reduceboxloners} |
| 2013 |
% Loop through the boxes and reduce the first loner found. |
| 2014 |
% \begin{macrocode} |
| 2015 |
%% Loop through the boxes, reducing loners |
| 2016 |
\newcommand*{\reduceboxloners}{\bgroup |
| 2017 |
\sumctr\z@ |
| 2018 |
\boxctr\@ne |
| 2019 |
\loop |
| 2020 |
\ifnum\boxctr<10\relax |
| 2021 |
% \end{macrocode} |
| 2022 |
% The next bit of code calculates the corner cell of the Nth box. |
| 2023 |
% \begin{macrocode} |
| 2024 |
\ifcase\boxctr |
| 2025 |
\or \s@lcnta=\@ne |
| 2026 |
\or \s@lcnta=4\relax |
| 2027 |
\or \s@lcnta=7\relax |
| 2028 |
\or \s@lcnta=28\relax |
| 2029 |
\or \s@lcnta=31\relax |
| 2030 |
\or \s@lcnta=34\relax |
| 2031 |
\or \s@lcnta=55\relax |
| 2032 |
\or \s@lcnta=58\relax |
| 2033 |
\or \s@lcnta=61\relax |
| 2034 |
\fi |
| 2035 |
\sumboxsets |
| 2036 |
\ifnum\sumctr>\z@ |
| 2037 |
\getloner{\the\sumctr}{\s@dtempcntb} |
| 2038 |
\ifnum\s@dtempcntb=\z@ |
| 2039 |
\else |
| 2040 |
\reducelonerboxcell{\the\s@lcnta}{\the\s@dtempcntb} |
| 2041 |
\iflonerchanged |
| 2042 |
\advance\boxctr 10\relax |
| 2043 |
\fi |
| 2044 |
\fi |
| 2045 |
\fi |
| 2046 |
\advance\boxctr\@ne |
| 2047 |
\repeat |
| 2048 |
\egroup} |
| 2049 |
|
| 2050 |
% \end{macrocode} |
| 2051 |
% \end{macro} |
| 2052 |
% |
| 2053 |
% \begin{macro}{\sumboxsets} |
| 2054 |
% Sum all the solution sets of the unsolved cells in the current box |
| 2055 |
% (\cs{s@lcnta}). The result is in \cs{sumctr}. |
| 2056 |
% \begin{macrocode} |
| 2057 |
%% add the sets in the current box |
| 2058 |
\newcommand*{\sumboxsets}{\bgroup |
| 2059 |
\s@dncol=\s@lcnta |
| 2060 |
\toprangectr=\s@dncol |
| 2061 |
\advance\toprangectr 3\relax |
| 2062 |
\global\sumctr\z@ |
| 2063 |
\loop |
| 2064 |
\ifnum\s@dncol<\toprangectr |
| 2065 |
\s@dnrow=\s@dncol |
| 2066 |
\ifnum\useknt{s@lans\the\s@dnrow}>\z@ |
| 2067 |
\global\advance\sumctr\useknt{s@lans\the\s@dnrow} |
| 2068 |
\fi |
| 2069 |
\advance\s@dnrow 9\relax |
| 2070 |
\ifnum\useknt{s@lans\the\s@dnrow}>\z@ |
| 2071 |
\global\advance\sumctr\useknt{s@lans\the\s@dnrow} |
| 2072 |
\fi |
| 2073 |
\advance\s@dnrow 9\relax |
| 2074 |
\ifnum\useknt{s@lans\the\s@dnrow}>\z@ |
| 2075 |
\global\advance\sumctr\useknt{s@lans\the\s@dnrow} |
| 2076 |
\fi |
| 2077 |
\advance\s@dncol\@ne |
| 2078 |
\repeat |
| 2079 |
\egroup} |
| 2080 |
|
| 2081 |
% \end{macrocode} |
| 2082 |
% \end{macro} |
| 2083 |
% |
| 2084 |
% \begin{macro}{\reducelonerboxcell} |
| 2085 |
% \cs{reducelonerboxcell}\marg{boxcell}\marg{digit}. |
| 2086 |
% Given (the cell at) the start of a box and a lone digit, find the cell |
| 2087 |
% in the box with that digit in its solution set, and make the digit |
| 2088 |
% the solution of that cell. |
| 2089 |
% \begin{macrocode} |
| 2090 |
%% \reducelonerboxcell{startofboxcell}{digit} |
| 2091 |
%% given a box and a lone digit, find the cell containing the digit |
| 2092 |
%% and make the digit a solution of that cell. |
| 2093 |
\newcommand*{\reducelonerboxcell}[2]{\bgroup |
| 2094 |
\s@dncol=\s@lcnta |
| 2095 |
\toprangectr=\s@dncol |
| 2096 |
\advance\toprangectr 3\relax |
| 2097 |
\global\sumctr\z@ |
| 2098 |
\loop |
| 2099 |
\ifnum\s@dncol<\toprangectr |
| 2100 |
\s@dnrow=\s@dncol |
| 2101 |
\numofnuminset{#2}{\the\useknt{s@lans\the\s@dnrow}}{\lonecellctr} |
| 2102 |
\ifnum\lonecellctr=\@ne% this cell has the loner |
| 2103 |
\lonecellctr=#2 |
| 2104 |
\global\useknt{s@lans\the\s@dnrow}=-\lonecellctr |
| 2105 |
\global\lonerchangedtrue |
| 2106 |
\global\advance\solcnt\@ne |
| 2107 |
\commentary{\the\solcnt\space solved (#2 loner in box starting #1)}% |
| 2108 |
\s@dncol=\toprangectr |
| 2109 |
\fi |
| 2110 |
\iflonerchanged\else |
| 2111 |
\advance\s@dnrow 9\relax |
| 2112 |
\numofnuminset{#2}{\the\useknt{s@lans\the\s@dnrow}}{\lonecellctr} |
| 2113 |
\ifnum\lonecellctr=\@ne% this cell has the loner |
| 2114 |
\lonecellctr=#2 |
| 2115 |
\global\useknt{s@lans\the\s@dnrow}=-\lonecellctr |
| 2116 |
\global\lonerchangedtrue |
| 2117 |
\global\advance\solcnt\@ne |
| 2118 |
\commentary{\the\solcnt\space solved (#2 loner in box starting #1)}% |
| 2119 |
\s@dncol=\toprangectr |
| 2120 |
\fi |
| 2121 |
\fi |
| 2122 |
\iflonerchanged\else |
| 2123 |
\advance\s@dnrow 9\relax |
| 2124 |
\numofnuminset{#2}{\the\useknt{s@lans\the\s@dnrow}}{\lonecellctr} |
| 2125 |
\ifnum\lonecellctr=\@ne% this cell has the loner |
| 2126 |
\lonecellctr=#2 |
| 2127 |
\global\useknt{s@lans\the\s@dnrow}=-\lonecellctr |
| 2128 |
\global\lonerchangedtrue |
| 2129 |
\global\advance\solcnt\@ne |
| 2130 |
\commentary{\the\solcnt\space solved (#2 loner in box starting #1)}% |
| 2131 |
\s@dncol=\toprangectr |
| 2132 |
\fi |
| 2133 |
\fi |
| 2134 |
\advance\s@dncol\@ne |
| 2135 |
\repeat |
| 2136 |
\egroup} |
| 2137 |
|
| 2138 |
% \end{macrocode} |
| 2139 |
% \end{macro} |
| 2140 |
% |
| 2141 |
% \begin{macrocode} |
| 2142 |
%%%%%%%%%%%%%%%%%%%%% reduce pairs %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2143 |
|
| 2144 |
% \end{macrocode} |
| 2145 |
% |
| 2146 |
% \begin{macro}{\reducepairs} |
| 2147 |
% Perform pair reduction, reducing the first pair found. First try |
| 2148 |
% by row, then by column, and lastly by box. |
| 2149 |
% \begin{macrocode} |
| 2150 |
%% reduce the pairs, per row, column and box |
| 2151 |
\newcommand*{\reducepairs}{\bgroup |
| 2152 |
\commentary{reducepairs}% **************************************}% |
| 2153 |
\global\pairchangedfalse |
| 2154 |
\ifnum\difficultyctr<8\relax |
| 2155 |
\global\difficultyctr=8\relax |
| 2156 |
\fi |
| 2157 |
\ifnum\solcnt>80\else |
| 2158 |
\reducerowpairs |
| 2159 |
\ifpairchanged\else |
| 2160 |
\reducecolpairs |
| 2161 |
\ifpairchanged\else |
| 2162 |
\reduceboxpairs |
| 2163 |
\fi |
| 2164 |
\fi |
| 2165 |
\fi |
| 2166 |
\egroup} |
| 2167 |
|
| 2168 |
% \end{macrocode} |
| 2169 |
% \end{macro} |
| 2170 |
% |
| 2171 |
% \begin{macro}{\reducerowpairs} |
| 2172 |
% Loop through the rows and reduce the first pair found. |
| 2173 |
% \begin{macrocode} |
| 2174 |
%% Loop through the rows, reducing pairs |
| 2175 |
\newcommand*{\reducerowpairs}{% |
| 2176 |
\sumctr\z@ |
| 2177 |
\s@dnrow\@ne |
| 2178 |
\loop |
| 2179 |
\ifnum\s@dnrow<10\relax |
| 2180 |
\s@lcnta=\s@dnrow \advance\s@lcnta\m@ne |
| 2181 |
\multiply\s@lcnta 9\relax \advance\s@lcnta\@ne |
| 2182 |
\sumrowsets |
| 2183 |
\ifnum\sumctr>\z@ |
| 2184 |
\reducearowpair{\the\s@lcnta} |
| 2185 |
\ifpairchanged |
| 2186 |
\advance\s@dnrow 10\relax |
| 2187 |
\fi |
| 2188 |
\fi |
| 2189 |
\advance\s@dnrow\@ne |
| 2190 |
\repeat} |
| 2191 |
|
| 2192 |
% \end{macrocode} |
| 2193 |
% \end{macro} |
| 2194 |
% |
| 2195 |
% \begin{macro}{\reducearowpair} |
| 2196 |
% \cs{reducearowpair}\marg{rowcell} reduces a pair in the row starting |
| 2197 |
% with cell \meta{rowcell}. |
| 2198 |
% \begin{macrocode} |
| 2199 |
%% reducearowpair{row} |
| 2200 |
\newcommand*{\reducearowpair}[1]{% |
| 2201 |
\bgroup |
| 2202 |
\s@dncol=#1\relax |
| 2203 |
\toprangectr=\s@dncol |
| 2204 |
\advance\toprangectr 9\relax |
| 2205 |
\maxrangectr=\toprangectr |
| 2206 |
\advance\maxrangectr\m@ne |
| 2207 |
\global\sumctr\z@ |
| 2208 |
\loop |
| 2209 |
\ifnum\s@dncol<\maxrangectr |
| 2210 |
\asetctr=\useknt{s@lans\the\s@dncol}% |
| 2211 |
\ifnum\asetctr>\z@ |
| 2212 |
\findrowpair |
| 2213 |
\fi |
| 2214 |
\advance\s@dncol\@ne |
| 2215 |
\repeat |
| 2216 |
\egroup} |
| 2217 |
|
| 2218 |
% \end{macrocode} |
| 2219 |
% \end{macro} |
| 2220 |
% |
| 2221 |
% \begin{macro}{\findrowpair} |
| 2222 |
% \cs{findrowpair} attempts to find a pair in the current row. |
| 2223 |
% \begin{macrocode} |
| 2224 |
\newcommand*{\findrowpair}{\bgroup |
| 2225 |
\secondctr=\s@dncol |
| 2226 |
\advance\secondctr\@ne |
| 2227 |
\loop |
| 2228 |
\ifnum\secondctr<\toprangectr |
| 2229 |
\ifnum\asetctr=\useknt{s@lans\the\secondctr} |
| 2230 |
\checksetforpair{\the\asetctr} |
| 2231 |
\ifnum\numdigitsctr=\tw@ |
| 2232 |
%% first row cell is \s@lcnta |
| 2233 |
%% first pair cell is \s@dncol, second pair cell is \secondctr |
| 2234 |
%% digits are \digitictr and \digitiictr |
| 2235 |
\deleterowpairdigits |
| 2236 |
\fi |
| 2237 |
\fi |
| 2238 |
\advance\secondctr\@ne |
| 2239 |
\repeat |
| 2240 |
\egroup} |
| 2241 |
|
| 2242 |
% \end{macrocode} |
| 2243 |
% \end{macro} |
| 2244 |
% |
| 2245 |
% \begin{macro}{\checksetforpair} |
| 2246 |
% \cs{checksetforpair}\marg{set} attempts to find a pair in a set. |
| 2247 |
% It sets \cs{digitictr} and \cs{digitiictr} as the first and second digits |
| 2248 |
% in the set and \cs{numdigitsctr} to the total number of digits in the |
| 2249 |
% set (which is 2 for a pair). |
| 2250 |
% \begin{macrocode} |
| 2251 |
%% \checksetforpair{set} returns with: |
| 2252 |
%% \digitictr = first digit |
| 2253 |
%% \digitiictr = second digit |
| 2254 |
%% \numdigitsctr = number of digits (2 for a pair) |
| 2255 |
\newcommand*{\checksetforpair}[1]{\bgroup |
| 2256 |
\s@dtemploopcnta\@ne |
| 2257 |
\global\numdigitsctr\z@ |
| 2258 |
\global\digitictr\z@ |
| 2259 |
\global\digitiictr\z@ |
| 2260 |
\loop |
| 2261 |
\ifnum\s@dtemploopcnta<10\relax |
| 2262 |
\numofnuminset{\the\s@dtemploopcnta}{#1}{\s@dtempcnta} |
| 2263 |
\ifnum\s@dtempcnta=\@ne |
| 2264 |
\global\advance\numdigitsctr\@ne |
| 2265 |
\ifcase\numdigitsctr |
| 2266 |
\or \global\digitictr=\s@dtemploopcnta |
| 2267 |
\or \global\digitiictr=\s@dtemploopcnta |
| 2268 |
\else \advance\s@dtemploopcnta 10\relax |
| 2269 |
\fi |
| 2270 |
\fi |
| 2271 |
\advance\s@dtemploopcnta\@ne |
| 2272 |
\repeat |
| 2273 |
\egroup} |
| 2274 |
|
| 2275 |
% \end{macrocode} |
| 2276 |
% \end{macro} |
| 2277 |
% |
| 2278 |
% \begin{macro}{\deleterowpairdigits} |
| 2279 |
% \cs{deleterowpairdigits} deletes the pair digits from non-pair cells |
| 2280 |
% in a row. The first cell in the row is \cs{s@lcnta}, the cells that |
| 2281 |
% contain the two pairs are \cs{s@dncol} and \cs{secondctr}, and the |
| 2282 |
% digits are \cs{digitictr} and \cs{digitiictr}. |
| 2283 |
% \begin{macrocode} |
| 2284 |
%% first row cell is \s@lcnta |
| 2285 |
%% first pair cell is \s@dncol, second pair cell is \secondctr |
| 2286 |
%% digits are \digitictr and \digitiictr |
| 2287 |
\newcommand*{\deleterowpairdigits}{\bgroup |
| 2288 |
\global\pairchangedfalse |
| 2289 |
\s@dtemploopcnta=\s@lcnta |
| 2290 |
\toprangectr=\s@dtemploopcnta \advance\toprangectr 9\relax |
| 2291 |
\loop |
| 2292 |
\ifnum\s@dtemploopcnta<\toprangectr |
| 2293 |
\ifnum\s@dtemploopcnta=\s@dncol |
| 2294 |
\else |
| 2295 |
\ifnum\s@dtemploopcnta=\secondctr |
| 2296 |
\else |
| 2297 |
\deletenumfromset{\the\digitictr}% |
| 2298 |
{\the\useknt{s@lans\the\s@dtemploopcnta}}{\s@dtempcnta} |
| 2299 |
\ifsetchanged |
| 2300 |
\global\useknt{s@lans\the\s@dtemploopcnta}=\s@dtempcnta |
| 2301 |
\global\pairchangedtrue |
| 2302 |
\fi |
| 2303 |
\deletenumfromset{\the\digitiictr}% |
| 2304 |
{\the\useknt{s@lans\the\s@dtemploopcnta}}{\s@dtempcnta} |
| 2305 |
\ifsetchanged |
| 2306 |
\global\useknt{s@lans\the\s@dtemploopcnta}=\s@dtempcnta |
| 2307 |
\global\pairchangedtrue |
| 2308 |
\fi |
| 2309 |
\fi |
| 2310 |
\fi |
| 2311 |
\advance\s@dtemploopcnta\@ne |
| 2312 |
\repeat |
| 2313 |
\egroup} |
| 2314 |
|
| 2315 |
% \end{macrocode} |
| 2316 |
% \end{macro} |
| 2317 |
% |
| 2318 |
% \begin{macro}{\reducecolpairs} |
| 2319 |
% Loop through the rows and reduce the first pair found. |
| 2320 |
% \begin{macrocode} |
| 2321 |
%% Loop through the columns, reducing pairs |
| 2322 |
\newcommand*{\reducecolpairs}{% |
| 2323 |
\sumctr\z@ |
| 2324 |
\s@dncol\@ne |
| 2325 |
\loop |
| 2326 |
\ifnum\s@dncol<10\relax |
| 2327 |
\s@lcnta=\s@dncol |
| 2328 |
\sumcolsets |
| 2329 |
\ifnum\sumctr>\z@ |
| 2330 |
\reduceacolpair{\the\s@lcnta} |
| 2331 |
\ifpairchanged |
| 2332 |
\advance\s@dncol 10\relax |
| 2333 |
\fi |
| 2334 |
\fi |
| 2335 |
\advance\s@dncol\@ne |
| 2336 |
\repeat} |
| 2337 |
|
| 2338 |
% \end{macrocode} |
| 2339 |
% \end{macro} |
| 2340 |
% |
| 2341 |
% \begin{macro}{\reduceacolpair} |
| 2342 |
% \cs{reduceacolpair}\marg{colcell} reduces a pair in the column starting |
| 2343 |
% with cell \meta{colcell}. |
| 2344 |
% \begin{macrocode} |
| 2345 |
%% reduceacolpair{col} |
| 2346 |
\newcommand*{\reduceacolpair}[1]{\bgroup |
| 2347 |
\s@dnrow=#1\relax |
| 2348 |
\toprangectr=\s@dnrow |
| 2349 |
\advance\toprangectr 73\relax |
| 2350 |
\maxrangectr=\toprangectr |
| 2351 |
\advance\maxrangectr -9\relax |
| 2352 |
\global\sumctr\z@ |
| 2353 |
\loop |
| 2354 |
\ifnum\s@dnrow<\maxrangectr |
| 2355 |
\asetctr=\useknt{s@lans\the\s@dnrow}% |
| 2356 |
\ifnum\asetctr>\z@ |
| 2357 |
\findcolpair |
| 2358 |
\fi |
| 2359 |
\advance\s@dnrow 9\relax |
| 2360 |
\repeat |
| 2361 |
\egroup} |
| 2362 |
|
| 2363 |
% \end{macrocode} |
| 2364 |
% \end{macro} |
| 2365 |
% |
| 2366 |
% \begin{macro}{\findcolpair} |
| 2367 |
% \cs{findcolpair} attempts to find a pair in the current column. |
| 2368 |
% \begin{macrocode} |
| 2369 |
\newcommand*{\findcolpair}{\bgroup |
| 2370 |
\secondctr=\s@dnrow |
| 2371 |
\advance\secondctr 9\relax |
| 2372 |
\loop |
| 2373 |
\ifnum\secondctr<\toprangectr |
| 2374 |
\ifnum\asetctr=\useknt{s@lans\the\secondctr} |
| 2375 |
\checksetforpair{\the\asetctr} |
| 2376 |
\ifnum\numdigitsctr=\tw@ |
| 2377 |
%% first row cell is \s@lcnta |
| 2378 |
%% first pair cell is \s@dnrow, second pair cell is \secondctr |
| 2379 |
%% digits are \digitictr and \digitiictr |
| 2380 |
\deletecolpairdigits |
| 2381 |
\fi |
| 2382 |
\fi |
| 2383 |
\advance\secondctr 9\relax |
| 2384 |
\repeat |
| 2385 |
\egroup} |
| 2386 |
|
| 2387 |
% \end{macrocode} |
| 2388 |
% \end{macro} |
| 2389 |
% |
| 2390 |
% \begin{macro}{\deletecolpairdigits} |
| 2391 |
% \cs{deletecolpairdigits} deletes the pair digits from non-pair cells |
| 2392 |
% in a column. The first cell in the column is \cs{s@lcnta}, the cells that |
| 2393 |
% contain the two pairs are \cs{s@dncol} and \cs{secondctr}, and the |
| 2394 |
% digits are \cs{digitictr} and \cs{digitiictr}. |
| 2395 |
% \begin{macrocode} |
| 2396 |
%% first col cell is \s@lcnta |
| 2397 |
%% first pair cell is \s@dnrow, second pair cell is \secondctr |
| 2398 |
%% digits are \digitictr and \digitiictr |
| 2399 |
\newcommand*{\deletecolpairdigits}{\bgroup |
| 2400 |
\global\pairchangedfalse |
| 2401 |
\s@dtemploopcnta=\s@lcnta |
| 2402 |
\toprangectr=\s@dtemploopcnta \advance\toprangectr 73\relax |
| 2403 |
\loop |
| 2404 |
\ifnum\s@dtemploopcnta<\toprangectr |
| 2405 |
\ifnum\s@dtemploopcnta=\s@dnrow |
| 2406 |
\else |
| 2407 |
\ifnum\s@dtemploopcnta=\secondctr |
| 2408 |
\else |
| 2409 |
\deletenumfromset{\the\digitictr}% |
| 2410 |
{\the\useknt{s@lans\the\s@dtemploopcnta}}{\s@dtempcnta} |
| 2411 |
\ifsetchanged |
| 2412 |
\global\useknt{s@lans\the\s@dtemploopcnta}=\s@dtempcnta |
| 2413 |
\global\pairchangedtrue |
| 2414 |
\fi |
| 2415 |
\deletenumfromset{\the\digitiictr}% |
| 2416 |
{\the\useknt{s@lans\the\s@dtemploopcnta}}{\s@dtempcnta} |
| 2417 |
\ifsetchanged |
| 2418 |
\global\useknt{s@lans\the\s@dtemploopcnta}=\s@dtempcnta |
| 2419 |
\global\pairchangedtrue |
| 2420 |
\fi |
| 2421 |
\fi |
| 2422 |
\fi |
| 2423 |
\advance\s@dtemploopcnta 9\relax |
| 2424 |
\repeat |
| 2425 |
\egroup} |
| 2426 |
|
| 2427 |
% \end{macrocode} |
| 2428 |
% \end{macro} |
| 2429 |
% |
| 2430 |
% \begin{macro}{\reduceboxpairs} |
| 2431 |
% Loop through the boxes and reduce the first pair found. |
| 2432 |
% \begin{macrocode} |
| 2433 |
%% Loop through the boxes, reducing pairs |
| 2434 |
\newcommand*{\reduceboxpairs}{\bgroup |
| 2435 |
\sumctr\z@ |
| 2436 |
\boxctr\@ne |
| 2437 |
\loop |
| 2438 |
\ifnum\boxctr<10\relax |
| 2439 |
\ifcase\boxctr |
| 2440 |
\or \s@lcnta=\@ne |
| 2441 |
\or \s@lcnta=4\relax |
| 2442 |
\or \s@lcnta=7\relax |
| 2443 |
\or \s@lcnta=28\relax |
| 2444 |
\or \s@lcnta=31\relax |
| 2445 |
\or \s@lcnta=34\relax |
| 2446 |
\or \s@lcnta=55\relax |
| 2447 |
\or \s@lcnta=58\relax |
| 2448 |
\or \s@lcnta=61\relax |
| 2449 |
\fi |
| 2450 |
\sumboxsets |
| 2451 |
\ifnum\sumctr>\z@ |
| 2452 |
\reduceaboxpair{\the\s@lcnta} |
| 2453 |
\ifpairchanged |
| 2454 |
\advance\boxctr 10\relax |
| 2455 |
\fi |
| 2456 |
\fi |
| 2457 |
\advance\boxctr\@ne |
| 2458 |
\repeat |
| 2459 |
\egroup} |
| 2460 |
|
| 2461 |
% \end{macrocode} |
| 2462 |
% \end{macro} |
| 2463 |
% |
| 2464 |
% \begin{macro}{\getnthboxcell} |
| 2465 |
% \cs{getnthboxcell}\marg{n}\marg{firstcell}\marg{cnt}. Given the first cell |
| 2466 |
% (\meta{firstcell}) in a box and a number, \meta{n}, between 1 and 9, set |
| 2467 |
% the \cs{count} \meta{cnt} to the cell number of the \meta{n}th cell in the |
| 2468 |
% box. |
| 2469 |
% \begin{macrocode} |
| 2470 |
%% \getnthboxcell{n}{firstcell}{returnctr} |
| 2471 |
\newcommand*{\getnthboxcell}[3]{\bgroup |
| 2472 |
\s@dtempcnta=#2 |
| 2473 |
\ifcase#1 |
| 2474 |
\or |
| 2475 |
\or \advance\s@dtempcnta 9\relax |
| 2476 |
\or \advance\s@dtempcnta 18\relax |
| 2477 |
\or \advance\s@dtempcnta \@ne |
| 2478 |
\or \advance\s@dtempcnta 10\relax |
| 2479 |
\or \advance\s@dtempcnta 19\relax |
| 2480 |
\or \advance\s@dtempcnta \tw@ |
| 2481 |
\or \advance\s@dtempcnta 11\relax |
| 2482 |
\or \advance\s@dtempcnta 20\relax |
| 2483 |
\fi |
| 2484 |
\global #3=\s@dtempcnta |
| 2485 |
\egroup} |
| 2486 |
|
| 2487 |
% \end{macrocode} |
| 2488 |
% \end{macro} |
| 2489 |
% |
| 2490 |
% \begin{macro}{\reduceaboxpair} |
| 2491 |
% \cs{reduceaboxpair}\marg{boxcell} reduces a pair in the box starting |
| 2492 |
% with cell \meta{boxcell}. |
| 2493 |
% \begin{macrocode} |
| 2494 |
%% \reduceaboxpair{startofboxcell} |
| 2495 |
\newcommand*{\reduceaboxpair}[1]{\bgroup |
| 2496 |
\s@dtemploopcnta\@ne |
| 2497 |
\toprangectr=\s@dtemploopcnta |
| 2498 |
\advance\toprangectr 9\relax |
| 2499 |
\maxrangectr=\toprangectr |
| 2500 |
\advance\maxrangectr\m@ne |
| 2501 |
\loop |
| 2502 |
\ifnum\s@dtemploopcnta<\maxrangectr |
| 2503 |
\getnthboxcell{\the\s@dtemploopcnta}{#1}{\s@dtempcnta} |
| 2504 |
\asetctr=\useknt{s@lans\the\s@dtempcnta} |
| 2505 |
\ifnum\asetctr>\z@ |
| 2506 |
\s@dnrow=\s@dtemploopcnta |
| 2507 |
\findboxpair{#1} |
| 2508 |
\fi |
| 2509 |
\advance\s@dtemploopcnta\@ne |
| 2510 |
\repeat |
| 2511 |
\egroup} |
| 2512 |
|
| 2513 |
% \end{macrocode} |
| 2514 |
% \end{macro} |
| 2515 |
% |
| 2516 |
% \begin{macro}{\findboxpair} |
| 2517 |
% \cs{findboxpair} attempts to find a pair in the current box, and then does |
| 2518 |
% a pair reduction for the box. |
| 2519 |
% \begin{macrocode} |
| 2520 |
%% \findboxpair{startofboxcell} |
| 2521 |
\newcommand*{\findboxpair}[1]{% |
| 2522 |
\bgroup |
| 2523 |
\secondctr=\s@dtemploopcnta |
| 2524 |
\advance\secondctr\@ne |
| 2525 |
\loop |
| 2526 |
\ifnum\secondctr<\toprangectr |
| 2527 |
\getnthboxcell{\the\secondctr}{#1}{\s@dtempcntb} |
| 2528 |
\ifnum\asetctr=\useknt{s@lans\the\s@dtempcntb} |
| 2529 |
\checksetforpair{\the\asetctr} |
| 2530 |
\ifnum\numdigitsctr=\tw@ |
| 2531 |
%% first box cell is #1 (=\s@lcnta) |
| 2532 |
%% first pair cell is \s@dnrow, second pair cell is \secondctr |
| 2533 |
%% digits are \digitictr and \digitiictr |
| 2534 |
\deleteboxpairdigits{#1} |
| 2535 |
\fi |
| 2536 |
\fi |
| 2537 |
\advance\secondctr \@ne |
| 2538 |
\repeat |
| 2539 |
\egroup} |
| 2540 |
|
| 2541 |
% \end{macrocode} |
| 2542 |
% \end{macro} |
| 2543 |
% |
| 2544 |
% \begin{macro}{\deleteboxpairdigits} |
| 2545 |
% \cs{deleteboxpairdigits}\marg{boxcell} deletes the pair digits from |
| 2546 |
% non-pair cells |
| 2547 |
% in a box. The first cell in the box is \meta{boxcell}, the cells that |
| 2548 |
% contain the two pairs are \cs{s@dnrow} and \cs{secondctr}, and the |
| 2549 |
% digits are \cs{digitictr} and \cs{digitiictr}. |
| 2550 |
% \begin{macrocode} |
| 2551 |
%% first box cell is #1 |
| 2552 |
%% first pair cell is \s@dnrow, second pair cell is \secondctr |
| 2553 |
%% digits are \digitictr and \digitiictr |
| 2554 |
\newcommand*{\deleteboxpairdigits}[1]{\bgroup |
| 2555 |
\global\pairchangedfalse |
| 2556 |
\s@dtemploopcnta=\@ne |
| 2557 |
\toprangectr=\s@dtemploopcnta \advance\toprangectr 9\relax |
| 2558 |
\loop |
| 2559 |
\ifnum\s@dtemploopcnta<\toprangectr |
| 2560 |
\ifnum\s@dtemploopcnta=\s@dnrow |
| 2561 |
\else |
| 2562 |
\ifnum\s@dtemploopcnta=\secondctr |
| 2563 |
\else |
| 2564 |
\getnthboxcell{\the\s@dtemploopcnta}{#1}{\s@dtempcntb} |
| 2565 |
\deletenumfromset{\the\digitictr}% |
| 2566 |
{\the\useknt{s@lans\the\s@dtempcntb}}{\s@dtempcnta} |
| 2567 |
\ifsetchanged |
| 2568 |
\global\useknt{s@lans\the\s@dtempcntb}=\s@dtempcnta |
| 2569 |
\global\pairchangedtrue |
| 2570 |
\fi |
| 2571 |
\deletenumfromset{\the\digitiictr}% |
| 2572 |
{\the\useknt{s@lans\the\s@dtempcntb}}{\s@dtempcnta} |
| 2573 |
\ifsetchanged |
| 2574 |
\global\useknt{s@lans\the\s@dtempcntb}=\s@dtempcnta |
| 2575 |
\global\pairchangedtrue |
| 2576 |
\fi |
| 2577 |
\fi |
| 2578 |
\fi |
| 2579 |
\advance\s@dtemploopcnta \@ne |
| 2580 |
\repeat |
| 2581 |
\egroup} |
| 2582 |
|
| 2583 |
% \end{macrocode} |
| 2584 |
% \end{macro} |
| 2585 |
% |
| 2586 |
% \subsubsection{Checking the solution} |
| 2587 |
% |
| 2588 |
% \begin{macrocode} |
| 2589 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% check solution %%%%%%%%%%%%%%%%%%%%%%%%% |
| 2590 |
|
| 2591 |
% \end{macrocode} |
| 2592 |
% |
| 2593 |
% We have found a solution when all the binary sets are negative. |
| 2594 |
% It's less efficient, but probably more useful, to check each |
| 2595 |
% row, column, and block (3 times 81 tests instead of 81). |
| 2596 |
% |
| 2597 |
% \begin{macro}{\checksolution} |
| 2598 |
% Check the solution by rows, columns, and boxes. |
| 2599 |
% \begin{macrocode} |
| 2600 |
\newcommand*{\checksolution}{% |
| 2601 |
\checkrows |
| 2602 |
\checkcols |
| 2603 |
\checkboxes} |
| 2604 |
|
| 2605 |
% \end{macrocode} |
| 2606 |
% \end{macro} |
| 2607 |
% |
| 2608 |
% \begin{macro}{\checkrows} |
| 2609 |
% Check the row solutions. A row is said to be correct if a solution has |
| 2610 |
% been assigned to each cell in the row, thus relying on the assumption |
| 2611 |
% that the solver never makes a mistake. The check is not sufficient for |
| 2612 |
% a solution obtained in another manner. |
| 2613 |
% \begin{macrocode} |
| 2614 |
\newcommand*{\checkrows}{% |
| 2615 |
\sumctr\z@ |
| 2616 |
\s@dnrow\@ne |
| 2617 |
\loop |
| 2618 |
\ifnum\s@dnrow<10\relax |
| 2619 |
\s@lcnta=\s@dnrow \advance\s@lcnta\m@ne |
| 2620 |
\multiply\s@lcnta 9\relax \advance\s@lcnta\@ne |
| 2621 |
\sumrowsets |
| 2622 |
\ifnum\sumctr=\z@\else |
| 2623 |
\typeout{Row \the\s@dnrow\space is incorrect}% |
| 2624 |
Row \the\s@dnrow\space is incorrect. \\ |
| 2625 |
\fi |
| 2626 |
\advance\s@dnrow\@ne |
| 2627 |
\repeat} |
| 2628 |
|
| 2629 |
% \end{macrocode} |
| 2630 |
% \end{macro} |
| 2631 |
% |
| 2632 |
% \begin{macro}{\checkcols} |
| 2633 |
% Check the column solutions. |
| 2634 |
% \begin{macrocode} |
| 2635 |
\newcommand*{\checkcols}{% |
| 2636 |
\bgroup |
| 2637 |
\sumctr\z@ |
| 2638 |
\s@dncol\@ne |
| 2639 |
\loop |
| 2640 |
\ifnum\s@dncol<10\relax |
| 2641 |
\s@lcnta=\s@dncol |
| 2642 |
\sumcolsets |
| 2643 |
\ifnum\sumctr=\z@\else |
| 2644 |
\typeout{Column \the\s@dncol\space is incorrect}% |
| 2645 |
Column \the\s@dncol\space is incorrect. \\ |
| 2646 |
\fi |
| 2647 |
\advance\s@dncol\@ne |
| 2648 |
\repeat |
| 2649 |
\egroup} |
| 2650 |
|
| 2651 |
% \end{macrocode} |
| 2652 |
% \end{macro} |
| 2653 |
% |
| 2654 |
% \begin{macro}{\checkboxes} |
| 2655 |
% Check the box solutions. |
| 2656 |
% \begin{macrocode} |
| 2657 |
\newcommand*{\checkboxes}{% |
| 2658 |
\bgroup |
| 2659 |
\sumctr\z@ |
| 2660 |
\boxctr\@ne |
| 2661 |
\loop |
| 2662 |
\ifnum\boxctr<10\relax |
| 2663 |
\ifcase\boxctr |
| 2664 |
\or \s@lcnta=\@ne |
| 2665 |
\or \s@lcnta=4\relax |
| 2666 |
\or \s@lcnta=7\relax |
| 2667 |
\or \s@lcnta=28\relax |
| 2668 |
\or \s@lcnta=31\relax |
| 2669 |
\or \s@lcnta=34\relax |
| 2670 |
\or \s@lcnta=55\relax |
| 2671 |
\or \s@lcnta=58\relax |
| 2672 |
\or \s@lcnta=61\relax |
| 2673 |
\fi |
| 2674 |
\sumboxsets |
| 2675 |
\ifnum\sumctr=\z@\else |
| 2676 |
\typeout{Box \the\boxctr\space is incorrect}% |
| 2677 |
Box \the\boxctr\space is incorrect. \\ |
| 2678 |
\fi |
| 2679 |
\advance\boxctr\@ne |
| 2680 |
\repeat |
| 2681 |
\egroup} |
| 2682 |
|
| 2683 |
% \end{macrocode} |
| 2684 |
% \end{macro} |
| 2685 |
% |
| 2686 |
% \begin{macro}{\typesimplestatusX} |
| 2687 |
% May be used to display the cuurrent status of the (partial) solution |
| 2688 |
% following simple reductions. |
| 2689 |
% \begin{macrocode} |
| 2690 |
%% typeset the current status of the partial solution |
| 2691 |
\newcommand*{\typesimplestatusX}{% |
| 2692 |
\par\noindent\begin{minipage}{\linewidth} |
| 2693 |
\begin{center} |
| 2694 |
Simple reductions stopped (with \the\solcnt\space solutions)\\ |
| 2695 |
%\footnotesize |
| 2696 |
\displaystatus |
| 2697 |
\end{center} |
| 2698 |
\end{minipage}} |
| 2699 |
|
| 2700 |
% \end{macrocode} |
| 2701 |
% \end{macro} |
| 2702 |
% |
| 2703 |
% \begin{macro}{\typelonestatusX} |
| 2704 |
% May be used to display the current status of the (partial) solution after a |
| 2705 |
% loner reduction. |
| 2706 |
% \begin{macrocode} |
| 2707 |
%% typeset the current status after loner processing |
| 2708 |
\newcommand*{\typelonestatusX}{% |
| 2709 |
\par\noindent\begin{minipage}{\linewidth} |
| 2710 |
\begin{center} |
| 2711 |
Loners processed (with \the\solcnt\space solutions)\\ |
| 2712 |
%\footnotesize |
| 2713 |
\displaystatus |
| 2714 |
\end{center} |
| 2715 |
\end{minipage}} |
| 2716 |
|
| 2717 |
% \end{macrocode} |
| 2718 |
% \end{macro} |
| 2719 |
% |
| 2720 |
% \begin{macro}{\hideprogress} |
| 2721 |
% \begin{macro}{\showprogess} |
| 2722 |
% Normally the progress towards a solution is not displayed. It will be |
| 2723 |
% displayed in the document, though, after the \cs{showprogress} declaration. |
| 2724 |
% The \cs{hideprogress} declaration switches off the displays. |
| 2725 |
% \begin{macrocode} |
| 2726 |
%% For curiosity as to how a solution is developing call the \showprogess |
| 2727 |
%% declaration (\hideprogess turns this off). |
| 2728 |
\newcommand*{\hideprogress}{% |
| 2729 |
\let\typesimplestatus\relax |
| 2730 |
\let\typelonestatus\relax} |
| 2731 |
\newcommand*{\showprogress}{% |
| 2732 |
\let\typesimplestatus\typesimplestatusX |
| 2733 |
\let\typelonestatus\typelonestatusX} |
| 2734 |
\hideprogress |
| 2735 |
%\showprogress |
| 2736 |
|
| 2737 |
% \end{macrocode} |
| 2738 |
% \end{macro} |
| 2739 |
% \end{macro} |
| 2740 |
% |
| 2741 |
% |
| 2742 |
% \begin{macrocode} |
| 2743 |
%%%%%%%%%%%%%%%%%% write solution to a game file %%%%%%%%%%%%%%% |
| 2744 |
|
| 2745 |
% \end{macrocode} |
| 2746 |
% |
| 2747 |
% \begin{macro}{\sudsolnfile} |
| 2748 |
% \begin{macro}{\writegame} |
| 2749 |
% \cs{writegame} writes the (partial) solution to the file \cs{sudsolnfile} |
| 2750 |
% (default \file{sud.out}). |
| 2751 |
% \begin{macrocode} |
| 2752 |
%% write out the solution to game file \sudsolnfile. |
| 2753 |
\newcommand*{\sudsolnfile}{sud.out} |
| 2754 |
\newcommand*{\writegame}{% |
| 2755 |
\immediate\closeout\s@dwrite |
| 2756 |
\immediate\openout\s@dwrite=\sudsolnfile |
| 2757 |
\s@dnrow\@ne |
| 2758 |
\loop |
| 2759 |
\ifnum\s@dnrow<81\relax |
| 2760 |
\gatherline{\the\s@dnrow} |
| 2761 |
\immediate\write\s@dwrite{\sudaline} |
| 2762 |
\advance\s@dnrow 9\relax |
| 2763 |
\repeat |
| 2764 |
\immediate\closeout\s@dwrite} |
| 2765 |
|
| 2766 |
% \end{macrocode} |
| 2767 |
% \end{macro} |
| 2768 |
% \end{macro} |
| 2769 |
% |
| 2770 |
% \begin{macro}{\gatherline} |
| 2771 |
% \begin{macro}{\sudaline} |
| 2772 |
% \cs{gatherline}\marg{rowstartcell} collects the solutions from one |
| 2773 |
% row in the grid |
| 2774 |
% and converts them into the corresponding characters for one line |
| 2775 |
% in a sudoku file, putting the characters into the \cs{sudaline} macro. |
| 2776 |
% \begin{macrocode} |
| 2777 |
%% \gatherline{colstart} |
| 2778 |
%% collect all the characters for one line in a game file |
| 2779 |
\newcommand*{\gatherline}[1]{\bgroup |
| 2780 |
\gdef\sudaline{} |
| 2781 |
\s@dncol=#1\relax |
| 2782 |
\toprangectr=\s@dncol |
| 2783 |
\advance\toprangectr 9\relax |
| 2784 |
\loop |
| 2785 |
\ifnum\s@dncol<\toprangectr |
| 2786 |
\s@dtempcnta=\useknt{s@lans\the\s@dncol} |
| 2787 |
\ifnum\s@dtempcnta>\m@ne |
| 2788 |
\g@addto@macro{\sudaline}{.} |
| 2789 |
\else |
| 2790 |
\s@dtempcnta=-\s@dtempcnta |
| 2791 |
\ifcase\s@dtempcnta |
| 2792 |
\or \g@addto@macro{\sudaline}{1} |
| 2793 |
\or \g@addto@macro{\sudaline}{2} |
| 2794 |
\or \g@addto@macro{\sudaline}{3} |
| 2795 |
\or \g@addto@macro{\sudaline}{4} |
| 2796 |
\or \g@addto@macro{\sudaline}{5} |
| 2797 |
\or \g@addto@macro{\sudaline}{6} |
| 2798 |
\or \g@addto@macro{\sudaline}{7} |
| 2799 |
\or \g@addto@macro{\sudaline}{8} |
| 2800 |
\or \g@addto@macro{\sudaline}{9} |
| 2801 |
\else \g@addto@macro{\sudaline}{.} |
| 2802 |
\fi |
| 2803 |
\fi |
| 2804 |
\advance\s@dncol\@ne |
| 2805 |
\repeat |
| 2806 |
\egroup} |
| 2807 |
|
| 2808 |
% \end{macrocode} |
| 2809 |
% \end{macro} |
| 2810 |
% \end{macro} |
| 2811 |
% |
| 2812 |
% \begin{macrocode} |
| 2813 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% THE END GOAL %%%%%%%%%%%%%%%%%%%%%%%%% |
| 2814 |
%%%%%%%%%%%%%%%%%%%%%%%%%%% \sudoksolve{<file>} %%%%%%%%%%%%%%%%%%%%%% |
| 2815 |
|
| 2816 |
% \end{macrocode} |
| 2817 |
% |
| 2818 |
% \begin{macro}{\sudokusolve} |
| 2819 |
% \cs{sudokesolve}\marg{file} reads a sudoku puzzle from the \meta{file} |
| 2820 |
% sudoku file, typesets the problem, does its best to solve it. |
| 2821 |
% It writes the solution to the \cs{sudsolnfile} file, then reads |
| 2822 |
% it back in again and typesets it. |
| 2823 |
% \begin{macrocode} |
| 2824 |
%% Read in and typeset the problem, solve it, and typeset the answer |
| 2825 |
\newcommand{\sudokusolve}[1]{% |
| 2826 |
\begin{center} |
| 2827 |
\sudoku{#1}% |
| 2828 |
\end{center} |
| 2829 |
\getproblem{#1}% |
| 2830 |
\reduceallcells |
| 2831 |
\keepreducing |
| 2832 |
\writegame |
| 2833 |
\noindent\begin{minipage}{\linewidth} |
| 2834 |
THE ANSWER |
| 2835 |
\begin{center} |
| 2836 |
\cluefont\normalsize |
| 2837 |
\cellsize{1.5\baselineskip} |
| 2838 |
\sudoku{\sudsolnfile} |
| 2839 |
\end{center} |
| 2840 |
\end{minipage}} |
| 2841 |
|
| 2842 |
% \end{macrocode} |
| 2843 |
% \end{macro} |
| 2844 |
% |
| 2845 |
% |
| 2846 |
% The end of the package. |
| 2847 |
% \begin{macrocode} |
| 2848 |
%</solve> |
| 2849 |
% \end{macrocode} |
| 2850 |
% |
| 2851 |
% |
| 2852 |
% \subsection{The \Lpack{createsudoku} package} |
| 2853 |
% |
| 2854 |
% The \Lpack{createsudoku} package lets you automatically generate |
| 2855 |
% Sudoku puzzles. The package requires Donald Arseneau's \file{random.tex} |
| 2856 |
% and also the \Lpack{solvesudoku} package, which in turn |
| 2857 |
% requires the \Lpack{printsudoku} package. |
| 2858 |
% |
| 2859 |
% \begin{macrocode} |
| 2860 |
%<*create> |
| 2861 |
\NeedsTeXFormat{LaTeX2e} |
| 2862 |
\ProvidesPackage{createsudoku}[2006/02/16 v1.0 create sudoku puzzles] |
| 2863 |
\input{random} |
| 2864 |
\RequirePackage{solvesudoku} |
| 2865 |
|
| 2866 |
% \end{macrocode} |
| 2867 |
% |
| 2868 |
% \begin{macro}{\oldcommentary} |
| 2869 |
% \begin{macro}{\commentary} |
| 2870 |
% \begin{macro}{\gencommentary} |
| 2871 |
% To avoid clutter it's a good |
| 2872 |
% idea to switch off \Lpack{solvesudoku}'s commentary. On the other hand |
| 2873 |
% it could be useful for this package to provide its own commentary. |
| 2874 |
% \begin{macrocode} |
| 2875 |
\let\oldcommentary\commentary |
| 2876 |
\let\commentary\@gobble |
| 2877 |
\newcommand*{\gencommentary}[1]{\typeout{#1}} |
| 2878 |
|
| 2879 |
% \end{macrocode} |
| 2880 |
% \end{macro} |
| 2881 |
% \end{macro} |
| 2882 |
% \end{macro} |
| 2883 |
% |
| 2884 |
% \begin{macro}{\genfile} |
| 2885 |
% \begin{macro}{\prevfile} |
| 2886 |
% \begin{macro}{\currfile} |
| 2887 |
% We need a file to write out the puxzzle to, and we also need two |
| 2888 |
% temporary files. |
| 2889 |
% \begin{macrocode} |
| 2890 |
\newcommand*{\genfile}{gensud.sud} |
| 2891 |
\newcommand*{\prevfile}{genprev.sdx} |
| 2892 |
\newcommand*{\currfile}{gencurr.sdx} |
| 2893 |
|
| 2894 |
% \end{macrocode} |
| 2895 |
% \end{macro} |
| 2896 |
% \end{macro} |
| 2897 |
% \end{macro} |
| 2898 |
% |
| 2899 |
% \begin{macro}{\randomi} |
| 2900 |
% \begin{macro}{\setsudrandom} |
| 2901 |
% This sets the seed for the random number generator. The default is |
| 2902 |
% setting it to -1, which makes the seed depend on the date and time. |
| 2903 |
% \begin{macrocode} |
| 2904 |
\randomi\m@ne |
| 2905 |
\newcommand*{\setsudrandom}[1]{% |
| 2906 |
\randomi=#1\relax |
| 2907 |
\ifnum\randomi<\@ne\else |
| 2908 |
\nextrandom \nextrandom \nextrandom |
| 2909 |
\typeout{random initialised to #1}% |
| 2910 |
\fi} |
| 2911 |
|
| 2912 |
% \end{macrocode} |
| 2913 |
% \end{macro} |
| 2914 |
% \end{macro} |
| 2915 |
% |
| 2916 |
% \begin{macro}{\generategrid} |
| 2917 |
% \begin{macro}{\printsudresults} |
| 2918 |
% \cs{generategrid}\oarg{file} generates a new puzzle. If the sudoko file |
| 2919 |
% \meta{file} is specified this is taken for the starting grid, otherwise |
| 2920 |
% a default one is used. The starting grid should be a complete solution. |
| 2921 |
% |
| 2922 |
% The pairs of rows, and pairs of columns, in the starting grid are |
| 2923 |
% exchanged in a random fashion (\cs{swaps}) and then the cell solutions |
| 2924 |
% are eliminated (\cs{elimclues}) until the puzzle is sufficiently complicated. |
| 2925 |
% \begin{macrocode} |
| 2926 |
\newcommand*{\generategrid}[1][\@empty]{% |
| 2927 |
\ifx\@empty #1 |
| 2928 |
\writestartgrid |
| 2929 |
\getproblem{\prevfile} |
| 2930 |
\else |
| 2931 |
\getproblem{#1} |
| 2932 |
\fi |
| 2933 |
\swaps |
| 2934 |
\elimclues |
| 2935 |
\printsudresults} |
| 2936 |
\newcommand*{\printsudresults}{% |
| 2937 |
\sudokusolve{\genfile}% |
| 2938 |
} |
| 2939 |
|
| 2940 |
% \end{macrocode} |
| 2941 |
% \end{macro} |
| 2942 |
% \end{macro} |
| 2943 |
% |
| 2944 |
% \begin{macro}{\writestartgrid} |
| 2945 |
% Write out an initial fully solved grid to \cs{prevfile}. |
| 2946 |
% \begin{macrocode} |
| 2947 |
%% the starting data |
| 2948 |
\newcommand*{\writestartgrid}{% |
| 2949 |
\immediate\closeout\s@dwrite |
| 2950 |
\immediate\openout\s@dwrite=\prevfile |
| 2951 |
\immediate\write\s@dwrite{123456789} |
| 2952 |
\immediate\write\s@dwrite{456789123} |
| 2953 |
\immediate\write\s@dwrite{789123456} |
| 2954 |
\immediate\write\s@dwrite{234567891} |
| 2955 |
\immediate\write\s@dwrite{567891234} |
| 2956 |
\immediate\write\s@dwrite{891234567} |
| 2957 |
\immediate\write\s@dwrite{345678912} |
| 2958 |
\immediate\write\s@dwrite{678912345} |
| 2959 |
\immediate\write\s@dwrite{912345678} |
| 2960 |
\immediate\closeout\s@dwrite} |
| 2961 |
|
| 2962 |
% \end{macrocode} |
| 2963 |
% \end{macro} |
| 2964 |
% |
| 2965 |
% \begin{macro}{\swaps} |
| 2966 |
% \cs{swaps} randomly exchanges the contents of pairs of columns and pairs |
| 2967 |
% of rows. In order to preserve the number uniqueness constraint for boxes, |
| 2968 |
% only pairs of columns/rows that are in the same box may be exchanged. |
| 2969 |
% \begin{macrocode} |
| 2970 |
\newcommand*{\swaps}{\bgroup |
| 2971 |
\setrannum{\maxrangectr}{36}{48}% |
| 2972 |
\gencommentary{number of swaps (36--48) = maxrangectr = \the\maxrangectr} |
| 2973 |
\s@dtemploopcnta\@ne |
| 2974 |
\loop |
| 2975 |
\ifnum\s@dtemploopcnta<\maxrangectr |
| 2976 |
\setrannum{\s@dtempcntb}{1}{18}% |
| 2977 |
%%\typeout{\space\space\space swap no \the\s@dtemploopcnta\space is \the\s@dtempcntb} |
| 2978 |
\ifcase\s@dtempcntb |
| 2979 |
\or \swapcolpair{1}{2}% |
| 2980 |
\or \swapcolpair{1}{3}% |
| 2981 |
\or \swapcolpair{2}{3}% |
| 2982 |
\or \swapcolpair{4}{5}% |
| 2983 |
\or \swapcolpair{4}{6}% |
| 2984 |
\or \swapcolpair{5}{6}% |
| 2985 |
\or \swapcolpair{7}{8}% |
| 2986 |
\or \swapcolpair{7}{9}% |
| 2987 |
\or \swapcolpair{8}{9}% |
| 2988 |
\or \swaprowpair{1}{10}% |
| 2989 |
\or \swaprowpair{1}{19}% |
| 2990 |
\or \swaprowpair{10}{19}% |
| 2991 |
\or \swaprowpair{28}{37}% |
| 2992 |
\or \swaprowpair{28}{46}% |
| 2993 |
\or \swaprowpair{37}{46}% |
| 2994 |
\or \swaprowpair{55}{64}% |
| 2995 |
\or \swaprowpair{55}{73}% |
| 2996 |
\or \swaprowpair{64}{73}% |
| 2997 |
\fi |
| 2998 |
\advance\s@dtemploopcnta\@ne |
| 2999 |
\repeat |
| 3000 |
\egroup} |
| 3001 |
|
| 3002 |
% \end{macrocode} |
| 3003 |
% \end{macro} |
| 3004 |
% |
| 3005 |
% \begin{macro}{\swaprowpair} |
| 3006 |
% \cs{swaprowpair}\marg{rowstartcell1}\marg{rowstartcell2} swaps the |
| 3007 |
% contents of the two rows starting at \meta{rowstartcell1} and |
| 3008 |
% \meta{rowstartcell2}. |
| 3009 |
% \begin{macrocode} |
| 3010 |
%% swap the data in rows starting at #1, and #2 |
| 3011 |
\newcommand*{\swaprowpair}[2]{\bgroup |
| 3012 |
\s@dncol=#1\relax |
| 3013 |
\s@dcolpos=#2\relax |
| 3014 |
\s@dtemploopcnta\@ne |
| 3015 |
\maxrangectr=10\relax |
| 3016 |
\loop |
| 3017 |
\ifnum\s@dtemploopcnta<\maxrangectr |
| 3018 |
\s@dtempcnta=\useknt{s@lans\the\s@dncol}% |
| 3019 |
\global\useknt{s@lans\the\s@dncol}=\useknt{s@lans\the\s@dcolpos}% |
| 3020 |
\global\useknt{s@lans\the\s@dcolpos}=\s@dtempcnta |
| 3021 |
\advance\s@dncol\@ne |
| 3022 |
\advance\s@dcolpos\@ne |
| 3023 |
\advance\s@dtemploopcnta\@ne |
| 3024 |
\repeat |
| 3025 |
\egroup} |
| 3026 |
|
| 3027 |
% \end{macrocode} |
| 3028 |
% \end{macro} |
| 3029 |
% |
| 3030 |
% \begin{macro}{\swapcolpair} |
| 3031 |
% \cs{swapcolpair}\marg{colstartcell1}\marg{colowstartcell2} swaps the |
| 3032 |
% contents of the two columns starting at \meta{colstartcell1} and |
| 3033 |
% \meta{colstartcell2}. |
| 3034 |
% \begin{macrocode} |
| 3035 |
%% swap the data in cols starting #1 and #2 |
| 3036 |
\newcommand*{\swapcolpair}[2]{\bgroup |
| 3037 |
\s@dnrow=#1\relax |
| 3038 |
\s@drowpos=#2\relax |
| 3039 |
\s@dtemploopcnta\@ne |
| 3040 |
\maxrangectr=10\relax |
| 3041 |
\loop |
| 3042 |
\ifnum\s@dtemploopcnta<\maxrangectr |
| 3043 |
\s@dtempcnta=\useknt{s@lans\the\s@dnrow}% |
| 3044 |
\global\useknt{s@lans\the\s@dnrow}=\useknt{s@lans\the\s@drowpos}% |
| 3045 |
\global\useknt{s@lans\the\s@drowpos}=\s@dtempcnta |
| 3046 |
\advance\s@dnrow 9\relax |
| 3047 |
\advance\s@drowpos 9\relax |
| 3048 |
\advance\s@dtemploopcnta\@ne |
| 3049 |
\repeat |
| 3050 |
\egroup} |
| 3051 |
|
| 3052 |
% \end{macrocode} |
| 3053 |
% \end{macro} |
| 3054 |
% |
| 3055 |
% \begin{macro}{\elimclues} |
| 3056 |
% \cs{elimclues} first eliminates a set of clues from the (full) grid, writing |
| 3057 |
% the resulting puzzle to the two temporary files \cs{prevfile} and |
| 3058 |
% \cs{currfile}. It |
| 3059 |
% then eliminates clues one-by-one until the puzzle has been finally |
| 3060 |
% generated, the result having been written to the \cs{prevfile}, |
| 3061 |
% then writing it out to the file \cs{genfile}. |
| 3062 |
% \begin{macrocode} |
| 3063 |
\newcommand*{\elimclues}{\bgroup |
| 3064 |
\initialelimination |
| 3065 |
\writestate{\prevfile}% |
| 3066 |
\writestate{\currfile}% |
| 3067 |
\elimcluesonebyone |
| 3068 |
\getproblem{\prevfile} |
| 3069 |
\writestate{\genfile} |
| 3070 |
\egroup} |
| 3071 |
|
| 3072 |
% \end{macrocode} |
| 3073 |
% \end{macro} |
| 3074 |
% |
| 3075 |
% \begin{macro}{\elimseventeen} |
| 3076 |
% \cs{elimseventeen} randomly eliminates the solutions for 17 cells in the |
| 3077 |
% grid (apparently if two numbers are completely eliminated as clues in a |
| 3078 |
% puzzle, then at best the solution is ambiguous). |
| 3079 |
% \begin{macrocode} |
| 3080 |
\newcommand*{\elimseventeen}{\bgroup |
| 3081 |
\s@dtemploopcnta\@ne |
| 3082 |
\maxrangectr 18\relax |
| 3083 |
\loop |
| 3084 |
\ifnum\s@dtemploopcnta<\maxrangectr |
| 3085 |
\setrannum{\s@dtempcnta}{1}{81} |
| 3086 |
\global\useknt{s@lans\the\s@dtempcnta}=111111111\relax |
| 3087 |
\advance\s@dtemploopcnta\@ne |
| 3088 |
\repeat |
| 3089 |
\egroup} |
| 3090 |
|
| 3091 |
% \end{macrocode} |
| 3092 |
% \end{macro} |
| 3093 |
% |
| 3094 |
% \begin{macro}{\elimcross} |
| 3095 |
% Eliminate all solutions in column 5 and row 5. |
| 3096 |
% \begin{macrocode} |
| 3097 |
%% eliminates all clues in column 5 and row 5 |
| 3098 |
\newcommand*{\elimcross}{\bgroup |
| 3099 |
\s@dtemploopcnta 5\relax |
| 3100 |
\loop |
| 3101 |
\ifnum\s@dtemploopcnta<78\relax% 78 = 5 + 73 |
| 3102 |
\global\useknt{s@lans\the\s@dtemploopcnta}=111111111\relax |
| 3103 |
\advance\s@dtemploopcnta 9\relax |
| 3104 |
\repeat |
| 3105 |
\s@dtemploopcnta 37\relax |
| 3106 |
\loop |
| 3107 |
\ifnum\s@dtemploopcnta<46\relax% 46 = 37 + 9 |
| 3108 |
\global\useknt{s@lans\the\s@dtemploopcnta}=111111111\relax |
| 3109 |
\advance\s@dtemploopcnta \@ne |
| 3110 |
\repeat |
| 3111 |
\egroup} |
| 3112 |
|
| 3113 |
% \end{macrocode} |
| 3114 |
% \end{macro} |
| 3115 |
% |
| 3116 |
% \begin{macro}{\elimnum} |
| 3117 |
% \cs{elimnum}\marg{num} (\verb?0 < num < 10?) eliminates all |
| 3118 |
% instances of the \meta{num} solution from the grid. |
| 3119 |
% \begin{macrocode} |
| 3120 |
\newcommand*{\elimnum}[1]{\bgroup |
| 3121 |
\s@dtemploopcnta\@ne |
| 3122 |
\loop |
| 3123 |
\ifnum\s@dtemploopcnta<82\relax |
| 3124 |
\ifnum\useknt{s@lans\the\s@dtemploopcnta}=-#1\relax |
| 3125 |
\global\useknt{s@lans\the\s@dtemploopcnta}=111111111\relax |
| 3126 |
\fi |
| 3127 |
\advance\s@dtemploopcnta \@ne |
| 3128 |
\repeat |
| 3129 |
\egroup} |
| 3130 |
|
| 3131 |
% \end{macrocode} |
| 3132 |
% \end{macro} |
| 3133 |
% |
| 3134 |
% \begin{macro}{\elimcrossandnines} |
| 3135 |
% Eliminate all 9's and the solutions in column 5 and row 5. |
| 3136 |
% \begin{macrocode} |
| 3137 |
\newcommand*{\elimcrossandnines}{\bgroup |
| 3138 |
\elimcross |
| 3139 |
\s@dtemploopcnta\@ne |
| 3140 |
\loop |
| 3141 |
\ifnum\s@dtemploopcnta<82\relax |
| 3142 |
\ifnum\useknt{s@lans\the\s@dtemploopcnta}=-9\relax |
| 3143 |
\global\useknt{s@lans\the\s@dtemploopcnta}=111111111\relax |
| 3144 |
\fi |
| 3145 |
\advance\s@dtemploopcnta \@ne |
| 3146 |
\repeat |
| 3147 |
\egroup} |
| 3148 |
|
| 3149 |
% \end{macrocode} |
| 3150 |
% \end{macro} |
| 3151 |
% |
| 3152 |
% \begin{macro}{\elimex} |
| 3153 |
% Eliminate all solutions on the diagonals of the grid. |
| 3154 |
% \begin{macrocode} |
| 3155 |
\newcommand*{\elimex}{\bgroup |
| 3156 |
\s@dtemploopcnta\@ne |
| 3157 |
\loop |
| 3158 |
\ifnum\s@dtemploopcnta<82\relax |
| 3159 |
\global\useknt{s@lans\the\s@dtemploopcnta}=111111111\relax |
| 3160 |
\advance\s@dtemploopcnta 10\relax |
| 3161 |
\repeat |
| 3162 |
\s@dtemploopcnta=9\relax |
| 3163 |
\loop |
| 3164 |
\ifnum\s@dtemploopcnta<81\relax |
| 3165 |
\global\useknt{s@lans\the\s@dtemploopcnta}=111111111\relax |
| 3166 |
\advance\s@dtemploopcnta 8\relax |
| 3167 |
\repeat |
| 3168 |
\egroup} |
| 3169 |
|
| 3170 |
% \end{macrocode} |
| 3171 |
% \end{macro} |
| 3172 |
% |
| 3173 |
% \begin{macro}{\elimcrossandex} |
| 3174 |
% Eliminate all solutions in column 5 and row 5 and on the diagonals. |
| 3175 |
% \begin{macrocode} |
| 3176 |
\newcommand*{\elimcrossandex}{\bgroup |
| 3177 |
\elimcross |
| 3178 |
\elimex |
| 3179 |
\egroup} |
| 3180 |
|
| 3181 |
% \end{macrocode} |
| 3182 |
% \end{macro} |
| 3183 |
% |
| 3184 |
% \begin{macro}{\elimcrossandexandnines} |
| 3185 |
% Eliminate all solutions in column 5 and row 5 and on the diagonals, |
| 3186 |
% and all 9's. |
| 3187 |
% \begin{macrocode} |
| 3188 |
\newcommand*{\elimcrossandexandnines}{\bgroup |
| 3189 |
\elimcross |
| 3190 |
\elimex |
| 3191 |
\elimnum{9} |
| 3192 |
\egroup} |
| 3193 |
|
| 3194 |
% \end{macrocode} |
| 3195 |
% \end{macro} |
| 3196 |
% |
| 3197 |
% \begin{macro}{\initialelimination} |
| 3198 |
% \cs{initialelimination} eliminates an initial set of solutions from the grid. |
| 3199 |
% Several predefined sets are provided. |
| 3200 |
% \begin{macrocode} |
| 3201 |
\let\initialelimination\elimseventeen |
| 3202 |
\let\initialelimination\elimcross |
| 3203 |
\let\initialelimination\elimcrossandnines |
| 3204 |
\let\initialelimination\elimcrossandex |
| 3205 |
\let\initialelimination\elimcrossandexandnines |
| 3206 |
|
| 3207 |
% \end{macrocode} |
| 3208 |
% \end{macro} |
| 3209 |
% |
| 3210 |
% |
| 3211 |
% \begin{macro}{\toomanyloops} |
| 3212 |
% \begin{macro}{\elimcluesonebyone} |
| 3213 |
% Eliminate solutions from the grid one-by-one until the puzzle cannot be |
| 3214 |
% solved. Then reinstate the last solution deleted to produce the final puzzle. |
| 3215 |
% I'm not sure if this is needed, but just in case the process stops after |
| 3216 |
% 81 attempts to remove solutions (highly unlikely but the random number |
| 3217 |
% generator could keep producing numbers corresponding to clueless cells). |
| 3218 |
% |
| 3219 |
% We use the \cs{currfile} and \cs{prevfile} to hold the current state of |
| 3220 |
% affairs and the previous state. |
| 3221 |
% \begin{macrocode} |
| 3222 |
\newcount\toomanyloops |
| 3223 |
\newcommand*{\elimcluesonebyone}{\bgroup |
| 3224 |
%%%\typeout{***elimcluesonebyone} |
| 3225 |
\toomanyloops\z@ |
| 3226 |
\s@dtempcntb=81\relax |
| 3227 |
\loop |
| 3228 |
\ifnum\s@dtempcntb>80\relax |
| 3229 |
\advance\toomanyloops\@ne |
| 3230 |
% \end{macrocode} |
| 3231 |
% Read the current puzzle from \cs{currfile} and try to solve it. |
| 3232 |
% \begin{macrocode} |
| 3233 |
\getproblem{\currfile} |
| 3234 |
\trysolution |
| 3235 |
\ifnum\solcnt=81\relax % can delete another clue |
| 3236 |
% \end{macrocode} |
| 3237 |
% The puzzle was solvable so try deleting another clue. Read the (unsolved) |
| 3238 |
% puzzle again from \cs{currfile} and write its state to \cs{prevfile}. |
| 3239 |
% \begin{macrocode} |
| 3240 |
\getproblem{\currfile} |
| 3241 |
\writestate{\prevfile} |
| 3242 |
% \end{macrocode} |
| 3243 |
% Now delete a clue, writing the resultant puzzle to \cs{currfile}, and |
| 3244 |
% go round the loop again. |
| 3245 |
% \begin{macrocode} |
| 3246 |
\deleteaclue |
| 3247 |
\writestate{\currfile}% |
| 3248 |
\s@dtempcntb=81\relax |
| 3249 |
\else % done |
| 3250 |
% \end{macrocode} |
| 3251 |
% The puzzle was not solvable, and the state before the last clue deletion |
| 3252 |
% is in file \cs{prevfile}. |
| 3253 |
% \begin{macrocode} |
| 3254 |
\typeout{Solver failed, solcnt = \the\solcnt} |
| 3255 |
\s@dtempcntb=\@ne |
| 3256 |
\fi |
| 3257 |
\ifnum\toomanyloops>80\relax |
| 3258 |
\typeout{Too much looping} |
| 3259 |
\s@dtempcntb=\@ne |
| 3260 |
\fi |
| 3261 |
\repeat |
| 3262 |
\egroup} |
| 3263 |
|
| 3264 |
% \end{macrocode} |
| 3265 |
% \end{macro} |
| 3266 |
% \end{macro} |
| 3267 |
% |
| 3268 |
% \begin{macro}{\ifacluenotdeleted} |
| 3269 |
% \begin{macro}{\deleteaclue} |
| 3270 |
% Keep calling the random number generator until it returns a cell that has |
| 3271 |
% a solution, |
| 3272 |
% then delete the solution. |
| 3273 |
% \begin{macrocode} |
| 3274 |
\newif\ifacluenotdeleted |
| 3275 |
\newcommand*{\deleteaclue}{\bgroup |
| 3276 |
\acluenotdeletedtrue |
| 3277 |
\loop |
| 3278 |
\ifacluenotdeleted |
| 3279 |
\setrannum{\s@dtempcnta}{1}{81}% |
| 3280 |
\ifnum\useknt{s@lans\the\s@dtempcnta}<\z@% found a clue |
| 3281 |
\gencommentary{Deleting clue for cell \the\s@dtempcnta}% |
| 3282 |
\global\useknt{s@lans\the\s@dtempcnta}=111111111\relax |
| 3283 |
\acluenotdeletedfalse |
| 3284 |
\fi |
| 3285 |
\repeat |
| 3286 |
\egroup} |
| 3287 |
|
| 3288 |
% \end{macrocode} |
| 3289 |
% \end{macro} |
| 3290 |
% \end{macro} |
| 3291 |
% |
| 3292 |
% \begin{macro}{\trysolution} |
| 3293 |
% \cs{trysolution} attempts to solve the current puzzle state. |
| 3294 |
% \begin{macrocode} |
| 3295 |
\newcommand*{\trysolution}{\bgroup |
| 3296 |
\reduceallcells |
| 3297 |
\keepreducing |
| 3298 |
\egroup} |
| 3299 |
|
| 3300 |
% \end{macrocode} |
| 3301 |
% \end{macro} |
| 3302 |
% |
| 3303 |
% \begin{macro}{\writestate} |
| 3304 |
% \cs{writestate}\marg{file} writes the current state (clues and blanks) |
| 3305 |
% to the sudoku file \meta{file}. |
| 3306 |
% \begin{macrocode} |
| 3307 |
%% \writestate{<outputfile>} |
| 3308 |
\newcommand*{\writestate}[1]{\bgroup |
| 3309 |
\immediate\closeout\s@dwrite |
| 3310 |
\immediate\openout\s@dwrite=#1 |
| 3311 |
\s@dnrow\@ne |
| 3312 |
\loop |
| 3313 |
\ifnum\s@dnrow<81\relax |
| 3314 |
\gatherline{\the\s@dnrow}% |
| 3315 |
\immediate\write\s@dwrite{\sudaline}% |
| 3316 |
\advance\s@dnrow 9\relax |
| 3317 |
\repeat |
| 3318 |
\immediate\closeout\s@dwrite |
| 3319 |
\egroup} |
| 3320 |
|
| 3321 |
% \end{macrocode} |
| 3322 |
% \end{macro} |
| 3323 |
% The end of the package. |
| 3324 |
% \begin{macrocode} |
| 3325 |
%</create> |
| 3326 |
% \end{macrocode} |
| 3327 |
% |
| 3328 |
% \section{Example sudoku puzzles} |
| 3329 |
% |
| 3330 |
% LaTeXing the following file will provide you with a selection of Sudoku |
| 3331 |
% puzzles. You can try solving them yourself and/or get Latex to do it for |
| 3332 |
% you. The \Lpack{solvesudoku} package is able to solve most, but not all |
| 3333 |
% of the puzzles. |
| 3334 |
% |
| 3335 |
% \begin{macrocode} |
| 3336 |
%<*examples> |
| 3337 |
\documentclass[twoside]{article} |
| 3338 |
\usepackage{comment} |
| 3339 |
\usepackage{url} |
| 3340 |
\usepackage{printsudoku} |
| 3341 |
\newcommand*{\Lpack}[1]{\textsf{#1}} |
| 3342 |
\title{Example Sudoku Puzzles} |
| 3343 |
\author{Peter Wilson} |
| 3344 |
\date{16 February 2006} |
| 3345 |
\raggedbottom |
| 3346 |
\begin{document} |
| 3347 |
\maketitle |
| 3348 |
|
| 3349 |
A Sudoku puzzle consists of a 9 by 9 array of squares, some of which have |
| 3350 |
numbers in them, the numbers ranging from 1 through 9. The problem is to |
| 3351 |
fill in all the squares such that each row, column, and 3 by 3 box includes |
| 3352 |
the numbers 1 through 9 with no repetitions. |
| 3353 |
|
| 3354 |
This is a collection of some 54 Sudoku puzzles which I have culled |
| 3355 |
from various places. The sources include, among others: |
| 3356 |
the \emph{Sudoku Solver}~\cite{SSBL} website (labelled SE, SM, SH and SVH), |
| 3357 |
\emph{The Daily Telegraph}~\cite{DT2} (labelled TG, TM, and TT), |
| 3358 |
\emph{The Seattle Times} (labelled ST), |
| 3359 |
and some automatically generated by the \Lpack{createsudoku} |
| 3360 |
package~\cite{SUDOKUBUNDLE} (labelled CS). |
| 3361 |
|
| 3362 |
You can try solving them yourself and/or get |
| 3363 |
LaTeX to do it for |
| 3364 |
you. The \Lpack{solvesudoku} package~\cite{SUDOKUBUNDLE} is able to solve |
| 3365 |
most, but not all of the puzzles. Other LaTeX packages may do better or worse. |
| 3366 |
|
| 3367 |
The puzzles are presented in approximately increasing order of difficulty. |
| 3368 |
Each source, though, has its own set of categories which don't necessarily |
| 3369 |
agree with each other (and sometimes not within one source). I have included |
| 3370 |
an indication of the difficulty as stated by the relevant source. |
| 3371 |
|
| 3372 |
The parameters for the puzzles created via \Lpack{createsudoku} are given in |
| 3373 |
the table. |
| 3374 |
|
| 3375 |
\begin{table}[hbp] |
| 3376 |
\centering |
| 3377 |
\begin{tabular}{lll} \hline |
| 3378 |
Number & Seed & \verb?initialelimination? \\ \hline |
| 3379 |
CS1 & 1505263462 & \verb?\elimcrossandexandnines? \\ |
| 3380 |
CS2 & 1495929734 & \verb?\elimcrossandex? \\ |
| 3381 |
CS3 & 1487762722 & \verb?\elimcrossandexandnines? \\ |
| 3382 |
CS4 & 1508763610 & \verb?\elimcrossandex? \\ |
| 3383 |
CS5 & 839068723 & \verb?\elimseventeen? \\ |
| 3384 |
CS6 & 833235143 & \verb?\elimcrossandexandnines? \\ \hline |
| 3385 |
\end{tabular} |
| 3386 |
\end{table} |
| 3387 |
|
| 3388 |
\cleardoublepage |
| 3389 |
|
| 3390 |
\cluefont{\LARGE} |
| 3391 |
\cellsize{2.25\baselineskip} |
| 3392 |
|
| 3393 |
\markboth{EASY}{EASY} |
| 3394 |
\pagestyle{headings} |
| 3395 |
|
| 3396 |
\renewcommand*{\puzzlefile}{se5.sud} |
| 3397 |
\writepuzzle% |
| 3398 |
{.2...5863}{56.2.3.9.}{.3...7251}% |
| 3399 |
{..975....}{..6..47.9}{.7..286..}% |
| 3400 |
{6.58...7.}{8....1..6}{3.7.6..4.}% |
| 3401 |
[SSBL easy 5] |
| 3402 |
\vfill |
| 3403 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 3404 |
SE5 (easy) \\ |
| 3405 |
\sudoku{se5.sud} |
| 3406 |
\end{center}\end{minipage} |
| 3407 |
|
| 3408 |
\renewcommand*{\puzzlefile}{se10.sud} |
| 3409 |
\writepuzzle% |
| 3410 |
{..6.497..}{.82.1.6..}{79..8.145}% |
| 3411 |
{649.5.27.}{..7.6..5.}{.3..72.96}% |
| 3412 |
{.2....81.}{.7..28...}{......5.7}% |
| 3413 |
[SSBL easy 10] |
| 3414 |
\vfill |
| 3415 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 3416 |
SE10 (easy) \\ |
| 3417 |
\sudoku{se10.sud} |
| 3418 |
\end{center}\end{minipage} |
| 3419 |
|
| 3420 |
\renewcommand*{\puzzlefile}{se15.sud} |
| 3421 |
\writepuzzle% |
| 3422 |
{4.67.39.2}{..16.84..}{.7...4..1}% |
| 3423 |
{5...4.21.}{.2.....6.}{.68.7...9}% |
| 3424 |
{6..5...9.}{..24.93..}{9.53.17.4}% |
| 3425 |
[SSBL easy 15] |
| 3426 |
\vfill |
| 3427 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 3428 |
SE15 (easy) \\ |
| 3429 |
\sudoku{se15.sud} |
| 3430 |
\end{center}\end{minipage} |
| 3431 |
|
| 3432 |
\renewcommand*{\puzzlefile}{se20.sud} |
| 3433 |
\writepuzzle% |
| 3434 |
{36.9..5..}{..54.8.2.}{.....78.9}% |
| 3435 |
{2....3.68}{.83.9....}{.4.7..2.3}% |
| 3436 |
{6.71..3..}{13.8.59.2}{..9.7..56}% |
| 3437 |
[SSBL easy 20] |
| 3438 |
\vfill |
| 3439 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 3440 |
SE20 (easy) \\ |
| 3441 |
\sudoku{se20.sud} |
| 3442 |
\end{center}\end{minipage} |
| 3443 |
|
| 3444 |
\renewcommand*{\puzzlefile}{se25.sud} |
| 3445 |
\writepuzzle% |
| 3446 |
{....63.5.}{6.5.1.839}{..1...2..}% |
| 3447 |
{823...7..}{.5...7...}{.64.9...1}% |
| 3448 |
{4.25796.3}{.9.1.65.8}{.1...89.7}% |
| 3449 |
[SSBL easy 25] |
| 3450 |
\vfill |
| 3451 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 3452 |
SE25 (easy) \\ |
| 3453 |
\sudoku{se25.sud} |
| 3454 |
\end{center}\end{minipage} |
| 3455 |
|
| 3456 |
\renewcommand*{\puzzlefile}{se30.sud} |
| 3457 |
\writepuzzle% |
| 3458 |
{.3.12....}{1.87..4.6}{..98....1}% |
| 3459 |
{5....7.3.}{.73.9.2.4}{.92..65..}% |
| 3460 |
{.4...8.5.}{3...7...8}{2..4.596.}% |
| 3461 |
[SSBL easy 30] |
| 3462 |
\vfill |
| 3463 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 3464 |
SE30 (easy) \\ |
| 3465 |
\sudoku{se30.sud} |
| 3466 |
\end{center}\end{minipage} |
| 3467 |
|
| 3468 |
\renewcommand*{\puzzlefile}{tg5.sud} |
| 3469 |
\writepuzzle% |
| 3470 |
{.6.1.9.8.}{.19...74.}{2.......1}% |
| 3471 |
{..79.26..}{.3.....2.}{..14.35..}% |
| 3472 |
{1.......5}{.75...23.}{.9.5.6.7.}% |
| 3473 |
[DT2 gentle 5] |
| 3474 |
\vfill |
| 3475 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 3476 |
TG5 (gentle) \\ |
| 3477 |
\sudoku{tg5.sud} |
| 3478 |
\end{center}\end{minipage} |
| 3479 |
|
| 3480 |
\renewcommand*{\puzzlefile}{tg10.sud} |
| 3481 |
\writepuzzle% |
| 3482 |
{....96..4}{..1.....2}{56...8...}% |
| 3483 |
{2.8....9.}{9.63.52.7}{.3....4.6}% |
| 3484 |
{...9...58}{7.....9..}{8..45....}% |
| 3485 |
[DT2 gentle 10] |
| 3486 |
\vfill |
| 3487 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 3488 |
TG10 (gentle) \\ |
| 3489 |
\sudoku{tg10.sud} |
| 3490 |
\end{center}\end{minipage} |
| 3491 |
|
| 3492 |
\renewcommand*{\puzzlefile}{tg15.sud} |
| 3493 |
\writepuzzle% |
| 3494 |
{...1.8...}{.57...18.}{98.....26}% |
| 3495 |
{..67419..}{.........}{..42536..}% |
| 3496 |
{72.....94}{.19...73.}{...3.9...}% |
| 3497 |
[DT2 gentle 15] |
| 3498 |
\vfill |
| 3499 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 3500 |
TG15 (gentle) \\ |
| 3501 |
\sudoku{tg15.sud} |
| 3502 |
\end{center}\end{minipage} |
| 3503 |
|
| 3504 |
\renewcommand*{\puzzlefile}{tg20.sud} |
| 3505 |
\writepuzzle% |
| 3506 |
{...7.9...}{.8.3.6.5.}{7.9...6.8}% |
| 3507 |
{..42.18..}{.6.....4.}{..35.41..}% |
| 3508 |
{9.2...5.7}{.4.8.7.1.}{...1.2...}% |
| 3509 |
[DT2 gentle 20] |
| 3510 |
\vfill |
| 3511 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 3512 |
TG20 (gentle) \\ |
| 3513 |
\sudoku{tg20.sud} |
| 3514 |
\end{center}\end{minipage} |
| 3515 |
|
| 3516 |
\renewcommand*{\puzzlefile}{tg25.sud} |
| 3517 |
\writepuzzle% |
| 3518 |
{7..4..5..}{.61..5.7.}{.9.7.1..6}% |
| 3519 |
{8...27...}{.........}{...34...1}% |
| 3520 |
{1..8.2.3.}{.7.1..62.}{..3..9..7}% |
| 3521 |
[DT2 gentle 25] |
| 3522 |
\vfill |
| 3523 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 3524 |
TG25 (gentle) \\ |
| 3525 |
\sudoku{tg25.sud} |
| 3526 |
\end{center}\end{minipage} |
| 3527 |
|
| 3528 |
\renewcommand*{\puzzlefile}{tg30.sud} |
| 3529 |
\writepuzzle% |
| 3530 |
{37.4.....}{9....61.4}{....23...}% |
| 3531 |
{.4.1..9..}{.12...79.}{..5..7.4.}% |
| 3532 |
{...36....}{4.32....6}{.....9.57}% |
| 3533 |
[DT2 gentle 30] |
| 3534 |
\vfill |
| 3535 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 3536 |
TG30 (gentle) \\ |
| 3537 |
\sudoku{tg30.sud} |
| 3538 |
\end{center}\end{minipage} |
| 3539 |
|
| 3540 |
\renewcommand*{\puzzlefile}{st1226.sud} |
| 3541 |
\writepuzzle% |
| 3542 |
{9....4.31}{7452.....}{.8..674..}% |
| 3543 |
{.26.4...5}{5..6.9..8}{4...2.37.}% |
| 3544 |
{..759..6.}{.....1823}{21.3....7}% |
| 3545 |
[Seattle Times 2005/12/26 1 star] |
| 3546 |
\vfill |
| 3547 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 3548 |
ST1226 (1 star) \\ |
| 3549 |
\sudoku{st1226.sud} |
| 3550 |
\end{center}\end{minipage} |
| 3551 |
|
| 3552 |
\renewcommand*{\puzzlefile}{st0206.sud} |
| 3553 |
\writepuzzle% |
| 3554 |
{17.42...5}{..2.1..96}{849..3...}% |
| 3555 |
{....718..}{.25...67.}{..826....}% |
| 3556 |
{...5..749}{53..9.1..}{6...48.23}% |
| 3557 |
[Seattle Times 2005/02/06 1 star] |
| 3558 |
\vfill |
| 3559 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 3560 |
ST0206 (1 star) \\ |
| 3561 |
\sudoku{st0206.sud} |
| 3562 |
\end{center}\end{minipage} |
| 3563 |
|
| 3564 |
\renewcommand*{\puzzlefile}{st0213.sud} |
| 3565 |
\writepuzzle% |
| 3566 |
{.94.2...7}{.36...1.5}{28.35....}% |
| 3567 |
{..92...5.}{6.21.49.8}{.7...63..}% |
| 3568 |
{....13.46}{1.5...78.}{8...4.29.}% |
| 3569 |
[Seattle Times 2006/02/13 1 star] |
| 3570 |
\vfill |
| 3571 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 3572 |
ST0213 (1 star) \\ |
| 3573 |
\sudoku{st0213.sud} |
| 3574 |
\end{center}\end{minipage} |
| 3575 |
|
| 3576 |
\renewcommand*{\puzzlefile}{cs1.sud} |
| 3577 |
\writepuzzle% |
| 3578 |
{.46..731.}{2.36.4...}{87.3.1.45}% |
| 3579 |
{657...423}{.........}{.81...756}% |
| 3580 |
{43.8.6..1}{7..2..5.4}{..25.386.}% |
| 3581 |
[CreateSudoku 1 (level 2)] |
| 3582 |
\vfill |
| 3583 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 3584 |
CS1 (level 2) \\ |
| 3585 |
\sudoku{cs1.sud} |
| 3586 |
\end{center}\end{minipage} |
| 3587 |
|
| 3588 |
\renewcommand*{\puzzlefile}{cs2.sud} |
| 3589 |
\writepuzzle% |
| 3590 |
{.7.3.265.}{...6..9.7}{64.9.8.2.}% |
| 3591 |
{..9...765}{.........}{756...4.2}% |
| 3592 |
{29.5...76}{...2.15.3}{..4..7.1.}% |
| 3593 |
[CreateSudoku 2 (level 2)] |
| 3594 |
\vfill |
| 3595 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 3596 |
CS2 (level 2) \\ |
| 3597 |
\sudoku{cs2.sud} |
| 3598 |
\end{center}\end{minipage} |
| 3599 |
|
| 3600 |
\renewcommand*{\puzzlefile}{cs3.sud} |
| 3601 |
\writepuzzle% |
| 3602 |
{.5.8.71..}{..35.....}{78.2.1.56}% |
| 3603 |
{.34...8.1}{.........}{8.1...56.}% |
| 3604 |
{.4.7.6.12}{...4.36.8}{.781..34.}% |
| 3605 |
[CreateSudoku 3 (level 2)] |
| 3606 |
\vfill |
| 3607 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 3608 |
CS3 (level 2) \\ |
| 3609 |
\sudoku{cs3.sud} |
| 3610 |
\end{center}\end{minipage} |
| 3611 |
|
| 3612 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% moderate |
| 3613 |
|
| 3614 |
\clearpage |
| 3615 |
\markboth{MODERATE}{MODERATE} |
| 3616 |
|
| 3617 |
\renewcommand*{\puzzlefile}{sm5.sud} |
| 3618 |
\writepuzzle% |
| 3619 |
{..76..24.}{.46....9.}{92..85...}% |
| 3620 |
{8....29..}{..3...4..}{..49....6}% |
| 3621 |
{...73..24}{.5....86.}{.32..67..}% |
| 3622 |
[SSBL medium 5] |
| 3623 |
\vfill |
| 3624 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 3625 |
SM5 (medium) \\ |
| 3626 |
\sudoku{sm5.sud} |
| 3627 |
\end{center}\end{minipage} |
| 3628 |
|
| 3629 |
\renewcommand*{\puzzlefile}{sm10.sud} |
| 3630 |
\writepuzzle% |
| 3631 |
{..57.82..}{4.......6}{.7..6..8.}% |
| 3632 |
{52.9.4.31}{.........}{86.1.7.54}% |
| 3633 |
{.9..3..6.}{7.......5}{..24.61..}% |
| 3634 |
[SSBL medium 10] |
| 3635 |
\vfill |
| 3636 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 3637 |
SM10 (medium) \\ |
| 3638 |
\sudoku{sm10.sud} |
| 3639 |
\end{center}\end{minipage} |
| 3640 |
|
| 3641 |
\renewcommand*{\puzzlefile}{sm15.sud} |
| 3642 |
\writepuzzle% |
| 3643 |
{85...4..2}{4...2.9..}{...8...7.}% |
| 3644 |
{..6.....1}{.4..8..3.}{2.....5..}% |
| 3645 |
{.34..7...}{.87.9...6}{6..1...47}% |
| 3646 |
[SSBL medium 15] |
| 3647 |
\vfill |
| 3648 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 3649 |
SM15 (medium) \\ |
| 3650 |
\sudoku{sm15.sud} |
| 3651 |
\end{center}\end{minipage} |
| 3652 |
|
| 3653 |
\renewcommand*{\puzzlefile}{sm20.sud} |
| 3654 |
\writepuzzle% |
| 3655 |
{..34.2.97}{..4....2.}{.7.6....8}% |
| 3656 |
{....9....}{.38...47.}{....1....}% |
| 3657 |
{4....5.1.}{.5....6..}{72.3.19..}% |
| 3658 |
[SSBL medium 20] |
| 3659 |
\vfill |
| 3660 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 3661 |
SM20 (medium) \\ |
| 3662 |
\sudoku{sm20.sud} |
| 3663 |
\end{center}\end{minipage} |
| 3664 |
|
| 3665 |
\renewcommand*{\puzzlefile}{sm25.sud} |
| 3666 |
\writepuzzle% |
| 3667 |
{...4.79..}{7.6...2..}{..5..83.6}% |
| 3668 |
{56..298..}{..8..1...}{.3.7....5}% |
| 3669 |
{.......38}{....93...}{.4.5.....}% |
| 3670 |
[SSBL medium 25] |
| 3671 |
\vfill |
| 3672 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 3673 |
SM25 (medium) \\ |
| 3674 |
\sudoku{sm25.sud} |
| 3675 |
\end{center}\end{minipage} |
| 3676 |
|
| 3677 |
\renewcommand*{\puzzlefile}{sm30.sud} |
| 3678 |
\writepuzzle% |
| 3679 |
{..58.....}{....79...}{..461..7.}% |
| 3680 |
{.5.3....4}{.23...65.}{9....8.3.}% |
| 3681 |
{.3..572..}{...42....}{.....61..}% |
| 3682 |
[SSBL medium 30] |
| 3683 |
\vfill |
| 3684 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 3685 |
SM30 (medium) \\ |
| 3686 |
\sudoku{sm30.sud} |
| 3687 |
\end{center}\end{minipage} |
| 3688 |
|
| 3689 |
\renewcommand*{\puzzlefile}{tm35.sud} |
| 3690 |
\writepuzzle% |
| 3691 |
{5..3.8..6}{..4.5.8..}{2.8...1.5}% |
| 3692 |
{..62.74..}{.........}{..94.32..}% |
| 3693 |
{9.5...6.4}{..2.1.9..}{1..8.9..2}% |
| 3694 |
[DT2 moderate 35] |
| 3695 |
\vfill |
| 3696 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 3697 |
TM35 (moderate) \\ |
| 3698 |
\sudoku{tm35.sud} |
| 3699 |
\end{center}\end{minipage} |
| 3700 |
|
| 3701 |
\renewcommand*{\puzzlefile}{tm40.sud} |
| 3702 |
\writepuzzle% |
| 3703 |
{...1...92}{9...7..36}{3....2...}% |
| 3704 |
{.3....7.9}{.8.9.5.6.}{4.5....8.}% |
| 3705 |
{...8....5}{54..2...7}{12...3...}% |
| 3706 |
[DT2 moderate 40] |
| 3707 |
\vfill |
| 3708 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 3709 |
TM40 (moderate) \\ |
| 3710 |
\sudoku{tm40.sud} |
| 3711 |
\end{center}\end{minipage} |
| 3712 |
|
| 3713 |
\renewcommand*{\puzzlefile}{tm45.sud} |
| 3714 |
\writepuzzle% |
| 3715 |
{.1.2.8.3.}{..87.94..}{9.......6}% |
| 3716 |
{..9.8.5..}{6.......3}{..3.5.6..}% |
| 3717 |
{2.......7}{..73.51..}{.6.4.7.9.}% |
| 3718 |
[DT2 moderate 45] |
| 3719 |
\vfill |
| 3720 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 3721 |
TM45 (moderate) \\ |
| 3722 |
\sudoku{tm45.sud} |
| 3723 |
\end{center}\end{minipage} |
| 3724 |
|
| 3725 |
\renewcommand*{\puzzlefile}{tm50.sud} |
| 3726 |
\writepuzzle% |
| 3727 |
{...9.2..4}{4..3.5...}{3.....7.6}% |
| 3728 |
{6..8..3..}{1.3...9.7}{..9..7..2}% |
| 3729 |
{9.5.....8}{...2.9..1}{2..7.4...}% |
| 3730 |
[DT2 moderate 50] |
| 3731 |
\vfill |
| 3732 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 3733 |
TM50 (moderate) \\ |
| 3734 |
\sudoku{tm50.sud} |
| 3735 |
\end{center}\end{minipage} |
| 3736 |
|
| 3737 |
\renewcommand*{\puzzlefile}{tm55.sud} |
| 3738 |
\writepuzzle% |
| 3739 |
{7........}{24.1.8...}{.6..72..3}% |
| 3740 |
{..4.29.8.}{.7.....6.}{.9.46.7..}% |
| 3741 |
{1..68..3.}{...3.7.91}{........6}% |
| 3742 |
[DT2 moderate 55] |
| 3743 |
\vfill |
| 3744 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 3745 |
TM55 (moderate) \\ |
| 3746 |
\sudoku{tm55.sud} |
| 3747 |
\end{center}\end{minipage} |
| 3748 |
|
| 3749 |
\renewcommand*{\puzzlefile}{tm60.sud} |
| 3750 |
\writepuzzle% |
| 3751 |
{724.9.5..}{.5..2...8}{.8.5.7...}% |
| 3752 |
{...7..64.}{....8....}{.79..6...}% |
| 3753 |
{...8.5.2.}{6...4..8.}{..8.3.174}% |
| 3754 |
[DT2 moderate 60] |
| 3755 |
\vfill |
| 3756 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 3757 |
TM60 (moderate) \\ |
| 3758 |
\sudoku{tm60.sud} |
| 3759 |
\end{center}\end{minipage} |
| 3760 |
|
| 3761 |
\renewcommand*{\puzzlefile}{st0914.sud} |
| 3762 |
\writepuzzle% |
| 3763 |
{.6.29..8.}{..8....3.}{.1..78...}% |
| 3764 |
{.217.9..8}{6.......3}{7..6.492.}% |
| 3765 |
{...12..4.}{.7....3..}{.5..86.7.}% |
| 3766 |
[Seattle Times 2005/09/14 2 stars] |
| 3767 |
\vfill |
| 3768 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 3769 |
ST0914 (2 stars) \\ |
| 3770 |
\sudoku{st0914.sud} |
| 3771 |
\end{center}\end{minipage} |
| 3772 |
|
| 3773 |
\renewcommand*{\puzzlefile}{st0207.sud} |
| 3774 |
\writepuzzle% |
| 3775 |
{.......46}{5..8.9.73}{...6..5.1}% |
| 3776 |
{.592..1..}{6...1...7}{..3..785.}% |
| 3777 |
{2.5..6...}{19.7.5..8}{34.......}% |
| 3778 |
[Seattle Times 2005/02/07 2 stars] |
| 3779 |
\vfill |
| 3780 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 3781 |
ST0207 (2 stars) \\ |
| 3782 |
\sudoku{st0207.sud} |
| 3783 |
\end{center}\end{minipage} |
| 3784 |
|
| 3785 |
\renewcommand*{\puzzlefile}{cs4.sud} |
| 3786 |
\writepuzzle% |
| 3787 |
{...4.597.}{..67.83.2}{78.1.2.45}% |
| 3788 |
{891...75.}{.........}{567...423}% |
| 3789 |
{.1...4.67}{..89.15..}{.4....29.}% |
| 3790 |
[CreateSudoku 4 (level 8)] |
| 3791 |
\vfill |
| 3792 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 3793 |
CS4 (level 4) \\ |
| 3794 |
\sudoku{cs4.sud} |
| 3795 |
\end{center}\end{minipage} |
| 3796 |
|
| 3797 |
\renewcommand*{\puzzlefile}{cs5.sud} |
| 3798 |
\writepuzzle% |
| 3799 |
{...6..978}{..498...2}{.97.21...}% |
| 3800 |
{..84.27..}{.7.....23}{3...6...9}% |
| 3801 |
{7.6..95..}{...87...1}{.2..4.867}% |
| 3802 |
[CreateSudoku 5 (level 4)] |
| 3803 |
\vfill |
| 3804 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 3805 |
CS5 (level 4) \\ |
| 3806 |
\sudoku{cs5.sud} |
| 3807 |
\end{center}\end{minipage} |
| 3808 |
|
| 3809 |
\renewcommand*{\puzzlefile}{cs6.sud} |
| 3810 |
\writepuzzle% |
| 3811 |
{.126.4.7.}{6.5..73.2}{.7.3.1.4.}% |
| 3812 |
{756...423}{.........}{18......6}% |
| 3813 |
{.3.8.6..1}{2.1.....7}{..72...3.}% |
| 3814 |
[CreateSudoku 6 (level 4)] |
| 3815 |
\vfill |
| 3816 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 3817 |
CS6 (level 4) \\ |
| 3818 |
\sudoku{cs6.sud} |
| 3819 |
\end{center}\end{minipage} |
| 3820 |
|
| 3821 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% hard |
| 3822 |
|
| 3823 |
\clearpage |
| 3824 |
\markboth{HARD}{HARD} |
| 3825 |
|
| 3826 |
\renewcommand*{\puzzlefile}{sh5.sud} |
| 3827 |
\writepuzzle% |
| 3828 |
{..9..5...}{47...2...}{.836.4.1.}% |
| 3829 |
{.15....8.}{...3.7...}{.2....74.}% |
| 3830 |
{.4.5.187.}{...7...52}{...2..1..}% |
| 3831 |
[SSBL hard 5] |
| 3832 |
\vfill |
| 3833 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 3834 |
SH5 (hard) \\ |
| 3835 |
\sudoku{sh5.sud} |
| 3836 |
\end{center}\end{minipage} |
| 3837 |
|
| 3838 |
\renewcommand*{\puzzlefile}{sh10.sud} |
| 3839 |
\writepuzzle% |
| 3840 |
{.3.921..5}{15.83....}{.........}% |
| 3841 |
{59......4}{37.....81}{6......53}% |
| 3842 |
{.........}{....19.26}{9..574.1.}% |
| 3843 |
[SSBL hard 10] |
| 3844 |
\vfill |
| 3845 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 3846 |
SH10 (hard) \\ |
| 3847 |
\sudoku{sh10.sud} |
| 3848 |
\end{center}\end{minipage} |
| 3849 |
|
| 3850 |
\renewcommand*{\puzzlefile}{sh15.sud} |
| 3851 |
\writepuzzle% |
| 3852 |
{2..9.....}{.7..6..59}{...4...61}% |
| 3853 |
{7.1..2..4}{....4....}{8..1..9.6}% |
| 3854 |
{12...3...}{53..2..7.}{.....9..2}% |
| 3855 |
[SSBL hard 15] |
| 3856 |
\vfill |
| 3857 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 3858 |
SH15 (hard) \\ |
| 3859 |
\sudoku{sh15.sud} |
| 3860 |
\end{center}\end{minipage} |
| 3861 |
|
| 3862 |
\renewcommand*{\puzzlefile}{sh20.sud} |
| 3863 |
\writepuzzle% |
| 3864 |
{.6.2...3.}{9...3...1}{....9.2..}% |
| 3865 |
{1..7.....}{.32...46.}{.....4..2}% |
| 3866 |
{..7.4....}{2...5...8}{.4...6.5.}% |
| 3867 |
[SSBL hard 20] |
| 3868 |
\vfill |
| 3869 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 3870 |
SH20 (hard) \\ |
| 3871 |
\sudoku{sh20.sud} |
| 3872 |
\end{center}\end{minipage} |
| 3873 |
|
| 3874 |
\renewcommand*{\puzzlefile}{sh25.sud} |
| 3875 |
\writepuzzle% |
| 3876 |
{4....1..8}{..7.3845.}{..24...1.}% |
| 3877 |
{28.9.....}{..4...5..}{.....4.86}% |
| 3878 |
{.4...92..}{.2134.8..}{9..6....1}% |
| 3879 |
[SSBL hard 25] |
| 3880 |
\vfill |
| 3881 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 3882 |
SH25 (hard) \\ |
| 3883 |
\sudoku{sh25.sud} |
| 3884 |
\end{center}\end{minipage} |
| 3885 |
|
| 3886 |
\renewcommand*{\puzzlefile}{sh30.sud} |
| 3887 |
\writepuzzle% |
| 3888 |
{....5..9.}{.53..78..}{78.4.....}% |
| 3889 |
{3....9.2.}{.72...38.}{.1.3....4}% |
| 3890 |
{.....1.35}{..58..41.}{.2..3....}% |
| 3891 |
[SSBL hard 30] |
| 3892 |
\vfill |
| 3893 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 3894 |
SH30 (hard) \\ |
| 3895 |
\sudoku{sh30.sud} |
| 3896 |
\end{center}\end{minipage} |
| 3897 |
|
| 3898 |
\renewcommand*{\puzzlefile}{tt100.sud} |
| 3899 |
\writepuzzle% |
| 3900 |
{...896..7}{..23.5...}{..8...5.1}% |
| 3901 |
{15...9...}{3.......9}{...6...54}% |
| 3902 |
{8.1...7..}{...9.18..}{6..428...}% |
| 3903 |
[DT2 tough 100] |
| 3904 |
\vfill |
| 3905 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 3906 |
TT100 (tough) \\ |
| 3907 |
\sudoku{tt100.sud} |
| 3908 |
\end{center}\end{minipage} |
| 3909 |
|
| 3910 |
\renewcommand*{\puzzlefile}{tt105.sud} |
| 3911 |
\writepuzzle% |
| 3912 |
{..5.7..46}{6..25....}{.3...6...}% |
| 3913 |
{2..7.....}{.78...35.}{.....1..7}% |
| 3914 |
{...8...2.}{....97..5}{81..2.9..}% |
| 3915 |
[DT2 tough 105] |
| 3916 |
\vfill |
| 3917 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 3918 |
TT105 (tough) \\ |
| 3919 |
\sudoku{tt105.sud} |
| 3920 |
\end{center}\end{minipage} |
| 3921 |
|
| 3922 |
\renewcommand*{\puzzlefile}{tt110.sud} |
| 3923 |
\writepuzzle% |
| 3924 |
{.79.1....}{.4.5....7}{1..6.....}% |
| 3925 |
{9368..1..}{..4...9..}{..7..4632}% |
| 3926 |
{.....8..1}{5....6.9.}{....4.82.}% |
| 3927 |
[DT2 tough 110] |
| 3928 |
\vfill |
| 3929 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 3930 |
TT110 (tough) \\ |
| 3931 |
\sudoku{tt110.sud} |
| 3932 |
\end{center}\end{minipage} |
| 3933 |
|
| 3934 |
\renewcommand*{\puzzlefile}{tt115.sud} |
| 3935 |
\writepuzzle% |
| 3936 |
{432.5....}{.....3...}{75.1.....}% |
| 3937 |
{..5.823..}{.6.5.1.4.}{..193.2..}% |
| 3938 |
{.....6.58}{...3.....}{....2.934}% |
| 3939 |
[DT2 tough 115] |
| 3940 |
\vfill |
| 3941 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 3942 |
TT115 (tough) \\ |
| 3943 |
\sudoku{tt115.sud} |
| 3944 |
\end{center}\end{minipage} |
| 3945 |
|
| 3946 |
\renewcommand*{\puzzlefile}{tt120.sud} |
| 3947 |
\writepuzzle% |
| 3948 |
{..8.1.7..}{.4.67.8..}{..2..461.}% |
| 3949 |
{.9....1.8}{.........}{2.1....9.}% |
| 3950 |
{.759..4..}{..4.52.6.}{..9.3.5..}% |
| 3951 |
[DT2 tough 120] |
| 3952 |
\vfill |
| 3953 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 3954 |
TT120 (tough) \\ |
| 3955 |
\sudoku{tt120.sud} |
| 3956 |
\end{center}\end{minipage} |
| 3957 |
|
| 3958 |
\renewcommand*{\puzzlefile}{st1130.sud} |
| 3959 |
\writepuzzle% |
| 3960 |
{8..356...}{5....4.1.}{34.......}% |
| 3961 |
{7.156..2.}{.6.....7.}{.2..796.5}% |
| 3962 |
{.......32}{.9.4....8}{...682..9}% |
| 3963 |
[Seattle Times 2005/11/30 3 stars] |
| 3964 |
\vfill |
| 3965 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 3966 |
ST1130 (3 stars) \\ |
| 3967 |
\sudoku{st1130.sud} |
| 3968 |
\end{center}\end{minipage} |
| 3969 |
|
| 3970 |
\renewcommand*{\puzzlefile}{st1207.sud} |
| 3971 |
\writepuzzle% |
| 3972 |
{...483..6}{.....57.2}{......38.}% |
| 3973 |
{..8..16..}{.26.5.17.}{..57..2..}% |
| 3974 |
{.82......}{9.18.....}{4..527...}% |
| 3975 |
[Seattle Times 2005/12/07 3 stars] |
| 3976 |
\vfill |
| 3977 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 3978 |
ST1207 (3 stars) \\ |
| 3979 |
\sudoku{st1207.sud} |
| 3980 |
\end{center}\end{minipage} |
| 3981 |
|
| 3982 |
\renewcommand*{\puzzlefile}{st1209.sud} |
| 3983 |
\writepuzzle% |
| 3984 |
{...6.....}{.4..8..5.}{.519..2.8}% |
| 3985 |
{..729...3}{.9.....1.}{4...679..}% |
| 3986 |
{6.8..957.}{.7..2..9.}{.....4...}% |
| 3987 |
[Seattle Times 2005/12/09 5 stars] |
| 3988 |
\vfill |
| 3989 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 3990 |
ST1209 (5 stars) \\ |
| 3991 |
\sudoku{st1209.sud} |
| 3992 |
\end{center}\end{minipage} |
| 3993 |
|
| 3994 |
\renewcommand*{\puzzlefile}{st1221.sud} |
| 3995 |
\writepuzzle% |
| 3996 |
{.....392.}{4....5.7.}{29.4...63}% |
| 3997 |
{..4....5.}{...2.1...}{.5....3..}% |
| 3998 |
{74...2.96}{.6.5....7}{.217.....}% |
| 3999 |
[Seattle Times 2005/12/21 3 stars] |
| 4000 |
\vfill |
| 4001 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 4002 |
ST1221 (3 stars) \\ |
| 4003 |
\sudoku{st1221.sud} |
| 4004 |
\end{center}\end{minipage} |
| 4005 |
|
| 4006 |
\renewcommand*{\puzzlefile}{st1228.sud} |
| 4007 |
\writepuzzle% |
| 4008 |
{6..1..5..}{......379}{.942.....}% |
| 4009 |
{..5...8.3}{.4.....9.}{9.7...6..}% |
| 4010 |
{.....623.}{138......}{..6..8..7}% |
| 4011 |
[Seattle Times 2005/12/28 3 stars] |
| 4012 |
\vfill |
| 4013 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 4014 |
ST1228 (3 stars) \\ |
| 4015 |
\sudoku{st1228.sud} |
| 4016 |
\end{center}\end{minipage} |
| 4017 |
|
| 4018 |
\renewcommand*{\puzzlefile}{st0126.sud} |
| 4019 |
\writepuzzle% |
| 4020 |
{..36...7.}{1...352..}{..4......}% |
| 4021 |
{..6....29}{7.......4}{32....5..}% |
| 4022 |
{......1..}{..824...5}{.4...93..}% |
| 4023 |
[Seattle Times 2006/01/26 4 stars] |
| 4024 |
\vfill |
| 4025 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 4026 |
ST0126 (4 stars) \\ |
| 4027 |
\sudoku{st0126.sud} |
| 4028 |
\end{center}\end{minipage} |
| 4029 |
|
| 4030 |
\renewcommand*{\puzzlefile}{st0127.sud} |
| 4031 |
\writepuzzle% |
| 4032 |
{25.8.....}{....9.8.2}{9..4.7...}% |
| 4033 |
{64.....9.}{.9.1.3.4.}{.7.....21}% |
| 4034 |
{...5.4..7}{7.6.8....}{.....1.83}% |
| 4035 |
[Seattle Times 2006/01/27 5 stars] |
| 4036 |
\vfill |
| 4037 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 4038 |
ST0127 (5 stars) \\ |
| 4039 |
\sudoku{st0127.sud} |
| 4040 |
\end{center}\end{minipage} |
| 4041 |
|
| 4042 |
\renewcommand*{\puzzlefile}{st0204.sud} |
| 4043 |
\writepuzzle% |
| 4044 |
{.5..2.8.6}{.....6..3}{.6..132..}% |
| 4045 |
{.7....96.}{4.......1}{.16....3.}% |
| 4046 |
{..723..8.}{6..7.....}{2.4.9..7.}% |
| 4047 |
[Seattle Times 2006/02/04 6 stars] |
| 4048 |
\vfill |
| 4049 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 4050 |
ST0204 (6 stars) \\ |
| 4051 |
\sudoku{st0204.sud} |
| 4052 |
\end{center}\end{minipage} |
| 4053 |
|
| 4054 |
\renewcommand*{\puzzlefile}{st0208.sud} |
| 4055 |
\writepuzzle% |
| 4056 |
{21.9....7}{5.9..421.}{..7......}% |
| 4057 |
{..875....}{3.14.95.8}{....361..}% |
| 4058 |
{......4..}{.325..9.1}{1....8.25}% |
| 4059 |
[Seattle Times 2005/02/08 3 stars] |
| 4060 |
\vfill |
| 4061 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 4062 |
ST0208 (3 stars) \\ |
| 4063 |
\sudoku{st0208.sud} |
| 4064 |
\end{center}\end{minipage} |
| 4065 |
|
| 4066 |
\renewcommand*{\puzzlefile}{st0209.sud} |
| 4067 |
\writepuzzle% |
| 4068 |
{..9......}{.523.1...}{8.12.6...}% |
| 4069 |
{..4....1.}{97..2..84}{.2....9..}% |
| 4070 |
{...8.41.5}{...6.524.}{......8..}% |
| 4071 |
[Seattle Times 2005/02/09 4 stars] |
| 4072 |
\vfill |
| 4073 |
\begin{minipage}{0.95\linewidth}\begin{center} |
| 4074 |
ST0209 (4 stars) \\ |
| 4075 |
\sudoku{st0209.sud} |
| 4076 |
\end{center}\end{minipage} |
| 4077 |
|
| 4078 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% answers |
| 4079 |
|
| 4080 |
\clearpage |
| 4081 |
\pagestyle{empty} |
| 4082 |
\cleardoublepage |
| 4083 |
\pagestyle{myheadings} |
| 4084 |
\markboth{SOLUTIONS}{SOLUTIONS} |
| 4085 |
|
| 4086 |
\cluefont{\normalsize} |
| 4087 |
\cellsize{1.5\baselineskip} |
| 4088 |
|
| 4089 |
\renewcommand*{\puzzlefile}{se5.ans} |
| 4090 |
\writepuzzle% |
| 4091 |
{724195863}{561283497}{938647251}% |
| 4092 |
{189756324}{256314789}{473928615}% |
| 4093 |
{645839172}{892471536}{317562948}% |
| 4094 |
[SSBL easy 5 solution] |
| 4095 |
\renewcommand*{\puzzlefile}{se10.ans} |
| 4096 |
\writepuzzle% |
| 4097 |
{156349782}{482715639}{793286145}% |
| 4098 |
{649853271}{217964358}{835172496}% |
| 4099 |
{524697813}{371528964}{968431527}% |
| 4100 |
[SSBL easy 10 solution] |
| 4101 |
\vfill |
| 4102 |
\noindent\begin{minipage}{0.47\linewidth}\begin{center} |
| 4103 |
SE5 (easy solution) \\ |
| 4104 |
\sudoku{se5.ans} |
| 4105 |
\end{center}\end{minipage} |
| 4106 |
\hfill |
| 4107 |
\begin{minipage}{0.47\linewidth}\begin{center} |
| 4108 |
SE10 (easy solution) \\ |
| 4109 |
\sudoku{se10.ans} |
| 4110 |
\end{center}\end{minipage} |
| 4111 |
|
| 4112 |
\renewcommand*{\puzzlefile}{se15.ans} |
| 4113 |
\writepuzzle% |
| 4114 |
{456713982}{231698475}{879254631}% |
| 4115 |
{597846213}{124935867}{368172549}% |
| 4116 |
{643527198}{712489356}{985361724}% |
| 4117 |
[SSBL easy 15 solution] |
| 4118 |
\renewcommand*{\puzzlefile}{se20.ans} |
| 4119 |
\writepuzzle% |
| 4120 |
{368912547}{975438621}{412657839}% |
| 4121 |
{291543768}{783296414}{546781293}% |
| 4122 |
{657129384}{134865972}{829374156}% |
| 4123 |
[SSBL easy 20 solution] |
| 4124 |
\vfill |
| 4125 |
\noindent\begin{minipage}{0.47\linewidth}\begin{center} |
| 4126 |
SE15 (easy solution) \\ |
| 4127 |
\sudoku{se15.ans} |
| 4128 |
\end{center}\end{minipage} |
| 4129 |
\hfill |
| 4130 |
\begin{minipage}{0.47\linewidth}\begin{center} |
| 4131 |
SE20 (easy solution) \\ |
| 4132 |
\sudoku{se20.ans} |
| 4133 |
\end{center}\end{minipage} |
| 4134 |
|
| 4135 |
\renewcommand*{\puzzlefile}{se25.ans} |
| 4136 |
\writepuzzle% |
| 4137 |
{278963154}{645712839}{931854276}% |
| 4138 |
{823641795}{159387462}{764295381}% |
| 4139 |
{482579613}{397126548}{516438927}% |
| 4140 |
[SSBL easy 25 solution] |
| 4141 |
\renewcommand*{\puzzlefile}{se30.ans} |
| 4142 |
\writepuzzle% |
| 4143 |
{436129875}{128753496}{759864321}% |
| 4144 |
{514287639}{673591284}{892346517}% |
| 4145 |
{941638752}{365972148}{287415963}% |
| 4146 |
[SSBL easy 30 solution] |
| 4147 |
\vfill |
| 4148 |
\noindent\begin{minipage}{0.47\linewidth}\begin{center} |
| 4149 |
SE25 (easy solution) \\ |
| 4150 |
\sudoku{se25.ans} |
| 4151 |
\end{center}\end{minipage} |
| 4152 |
\hfill |
| 4153 |
\begin{minipage}{0.47\linewidth}\begin{center} |
| 4154 |
SE30 (easy solution) \\ |
| 4155 |
\sudoku{se30.ans} |
| 4156 |
\end{center}\end{minipage} |
| 4157 |
|
| 4158 |
\renewcommand*{\puzzlefile}{tg5.ans} |
| 4159 |
\writepuzzle% |
| 4160 |
{764159382}{519238746}{823674951}% |
| 4161 |
{457982613}{936715428}{281463597}% |
| 4162 |
{142397865}{675841239}{398526174}% |
| 4163 |
[DT2 gentle 5 solution] |
| 4164 |
\renewcommand*{\puzzlefile}{tg10.ans} |
| 4165 |
\writepuzzle% |
| 4166 |
{382196574}{491573862}{567248139}% |
| 4167 |
{278614395}{946385217}{135729486}% |
| 4168 |
{624931758}{753862941}{819457623}% |
| 4169 |
[DT2 gentle 10 solution] |
| 4170 |
\vfill |
| 4171 |
\noindent\begin{minipage}{0.47\linewidth}\begin{center} |
| 4172 |
TG5 (gentle solution) \\ |
| 4173 |
\sudoku{tg5.ans} |
| 4174 |
\end{center}\end{minipage} |
| 4175 |
\hfill |
| 4176 |
\begin{minipage}{0.47\linewidth}\begin{center} |
| 4177 |
TG10 (gentle solution) \\ |
| 4178 |
\sudoku{tg10.ans} |
| 4179 |
\end{center}\end{minipage} |
| 4180 |
|
| 4181 |
\renewcommand*{\puzzlefile}{tg15.ans} |
| 4182 |
\writepuzzle% |
| 4183 |
{462198573}{357462189}{981537426}% |
| 4184 |
{236741958}{175986342}{894253617}% |
| 4185 |
{723615894}{619824735}{548379261}% |
| 4186 |
[DT2 gentle 15 solution] |
| 4187 |
\renewcommand*{\puzzlefile}{tg20.ans} |
| 4188 |
\writepuzzle% |
| 4189 |
{256789431}{481326759}{739415628}% |
| 4190 |
{594261873}{167938245}{823574196}% |
| 4191 |
{912643587}{645897312}{378152964}% |
| 4192 |
[DT2 gentle 20 solution] |
| 4193 |
\vfill |
| 4194 |
\noindent\begin{minipage}{0.47\linewidth}\begin{center} |
| 4195 |
TG15 (gentle solution) \\ |
| 4196 |
\sudoku{tg15.ans} |
| 4197 |
\end{center}\end{minipage} |
| 4198 |
\hfill |
| 4199 |
\begin{minipage}{0.47\linewidth}\begin{center} |
| 4200 |
TG20 (gentle solution) \\ |
| 4201 |
\sudoku{tg20.ans} |
| 4202 |
\end{center}\end{minipage} |
| 4203 |
|
| 4204 |
\renewcommand*{\puzzlefile}{tg25.ans} |
| 4205 |
\writepuzzle% |
| 4206 |
{782463519}{461295378}{395781246}% |
| 4207 |
{819527463}{634918752}{527346891}% |
| 4208 |
{256872934}{978134625}{243659187}% |
| 4209 |
[DT2 gentle 25 solution] |
| 4210 |
\renewcommand*{\puzzlefile}{tg30.ans} |
| 4211 |
\writepuzzle% |
| 4212 |
{376418529}{928756134}{154923678}% |
| 4213 |
{749132865}{612584793}{835697241}% |
| 4214 |
{597361482}{483275916}{261849357}% |
| 4215 |
[DT2 gentle 30 solution] |
| 4216 |
\vfill |
| 4217 |
\noindent\begin{minipage}{0.47\linewidth}\begin{center} |
| 4218 |
TG25 (gentle solution) \\ |
| 4219 |
\sudoku{tg25.ans} |
| 4220 |
\end{center}\end{minipage} |
| 4221 |
\hfill |
| 4222 |
\begin{minipage}{0.47\linewidth}\begin{center} |
| 4223 |
TG30 (gentle solution) \\ |
| 4224 |
\sudoku{tg30.ans} |
| 4225 |
\end{center}\end{minipage} |
| 4226 |
|
| 4227 |
\renewcommand*{\puzzlefile}{st1226.ans} |
| 4228 |
\writepuzzle% |
| 4229 |
{962854731}{745213689}{183967452}% |
| 4230 |
{326748915}{571639248}{498125376}% |
| 4231 |
{837592164}{659471823}{214386597}% |
| 4232 |
[Seattle Times 2005/12/26 1 star solution] |
| 4233 |
\renewcommand*{\puzzlefile}{st0206.ans} |
| 4234 |
\writepuzzle% |
| 4235 |
{176429385}{352817496}{849653217}% |
| 4236 |
{463971852}{925384671}{718265934}% |
| 4237 |
{281536749}{534792168}{697148523}% |
| 4238 |
[Seattle Times 2005/02/06 1 star solution] |
| 4239 |
\vfill |
| 4240 |
\noindent\begin{minipage}{0.47\linewidth}\begin{center} |
| 4241 |
ST1226 (1 star solution) \\ |
| 4242 |
\sudoku{st1226.ans} |
| 4243 |
\end{center}\end{minipage} |
| 4244 |
\hfill |
| 4245 |
\begin{minipage}{0.47\linewidth}\begin{center} |
| 4246 |
ST0206 (1 star solution) \\ |
| 4247 |
\sudoku{st0206.ans} |
| 4248 |
\end{center}\end{minipage} |
| 4249 |
|
| 4250 |
\renewcommand*{\puzzlefile}{st0123.ans} |
| 4251 |
\writepuzzle% |
| 4252 |
{594621837}{736489125}{281357469}% |
| 4253 |
{319278654}{652134978}{478596312}% |
| 4254 |
{927813546}{145962783}{863745291}% |
| 4255 |
[Seattle Times 2006/01/23 1 star solution] |
| 4256 |
\renewcommand*{\puzzlefile}{cs1.ans} |
| 4257 |
\writepuzzle% |
| 4258 |
{546987312}{213654978}{879321645}% |
| 4259 |
{657198423}{324765189}{981432756}% |
| 4260 |
{435876291}{768219534}{192543867}% |
| 4261 |
[CreateSudoku 1 (level 2) solution] |
| 4262 |
\vfill |
| 4263 |
\noindent\begin{minipage}{0.47\linewidth}\begin{center} |
| 4264 |
ST0123 (1 star solution) \\ |
| 4265 |
\sudoku{st0123.ans} |
| 4266 |
\end{center}\end{minipage} |
| 4267 |
\hfill |
| 4268 |
\begin{minipage}{0.47\linewidth}\begin{center} |
| 4269 |
CS1 (level 2 solution) \\ |
| 4270 |
\sudoku{cs1.ans} |
| 4271 |
\end{center}\end{minipage} |
| 4272 |
|
| 4273 |
\renewcommand*{\puzzlefile}{cs2.ans} |
| 4274 |
\writepuzzle% |
| 4275 |
{978312654}{312645987}{645978321}% |
| 4276 |
{189423765}{423756198}{756189432}% |
| 4277 |
{291534876}{867291543}{534867219}% |
| 4278 |
[CreateSudoku 2 (level 2) solution] |
| 4279 |
\renewcommand*{\puzzlefile}{cs3.ans} |
| 4280 |
\writepuzzle% |
| 4281 |
{456897123}{123564789}{789231456}% |
| 4282 |
{234675891}{567918234}{891342567}% |
| 4283 |
{345786912}{912453678}{678129345}% |
| 4284 |
[CreateSudoku 3 (level 2) solution] |
| 4285 |
\vfill |
| 4286 |
\noindent\begin{minipage}{0.47\linewidth}\begin{center} |
| 4287 |
CS2 (level 2 solution) \\ |
| 4288 |
\sudoku{cs2.ans} |
| 4289 |
\end{center}\end{minipage} |
| 4290 |
\hfill |
| 4291 |
\begin{minipage}{0.47\linewidth}\begin{center} |
| 4292 |
CS3 (level 2 solution) \\ |
| 4293 |
\sudoku{cs3.ans} |
| 4294 |
\end{center}\end{minipage} |
| 4295 |
|
| 4296 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% medium |
| 4297 |
|
| 4298 |
\renewcommand*{\puzzlefile}{sm5.ans} |
| 4299 |
\writepuzzle% |
| 4300 |
{387691245}{546273198}{921485637}% |
| 4301 |
{865342971}{193567482}{274918356}% |
| 4302 |
{618739524}{759124863}{432856719}% |
| 4303 |
[SSBL medium 5 solution] |
| 4304 |
\renewcommand*{\puzzlefile}{sm10.ans} |
| 4305 |
\writepuzzle% |
| 4306 |
{635748219}{418392576}{279561483}% |
| 4307 |
{527984631}{941653827}{863127954}% |
| 4308 |
{194835762}{786219345}{352476198}% |
| 4309 |
[SSBL medium 10 solution] |
| 4310 |
\vfill |
| 4311 |
\noindent\begin{minipage}{0.47\linewidth}\begin{center} |
| 4312 |
SM5 (medium solution) \\ |
| 4313 |
\sudoku{sm5.ans} |
| 4314 |
\end{center}\end{minipage} |
| 4315 |
\hfill |
| 4316 |
\begin{minipage}{0.47\linewidth}\begin{center} |
| 4317 |
SM10 (medium solution) \\ |
| 4318 |
\sudoku{sm10.ans} |
| 4319 |
\end{center}\end{minipage} |
| 4320 |
|
| 4321 |
\renewcommand*{\puzzlefile}{sm15.ans} |
| 4322 |
\writepuzzle% |
| 4323 |
{853974612}{471326958}{962815473}% |
| 4324 |
{396542781}{745681239}{218739564}% |
| 4325 |
{134267895}{587493126}{629158347}% |
| 4326 |
[SSBL medium 15 solution] |
| 4327 |
\renewcommand*{\puzzlefile}{sm20.ans} |
| 4328 |
\writepuzzle% |
| 4329 |
{863452197}{594178326}{172639548}% |
| 4330 |
{617894235}{938526471}{234713869}% |
| 4331 |
{489265713}{351947682}{726381954}% |
| 4332 |
[SSBL medium 20 solution] |
| 4333 |
\vfill |
| 4334 |
\noindent\begin{minipage}{0.47\linewidth}\begin{center} |
| 4335 |
SM15 (medium solution) \\ |
| 4336 |
\sudoku{sm15.ans} |
| 4337 |
\end{center}\end{minipage} |
| 4338 |
\hfill |
| 4339 |
\begin{minipage}{0.47\linewidth}\begin{center} |
| 4340 |
SM20 (medium solution) \\ |
| 4341 |
\sudoku{sm20.ans} |
| 4342 |
\end{center}\end{minipage} |
| 4343 |
|
| 4344 |
\renewcommand*{\puzzlefile}{sm25.ans} |
| 4345 |
\writepuzzle% |
| 4346 |
{382467951}{716935284}{495218376}% |
| 4347 |
{564329817}{278651493}{139784625}% |
| 4348 |
{927146538}{651893742}{843572169}% |
| 4349 |
[SSBL medium 25 solution] |
| 4350 |
\renewcommand*{\puzzlefile}{sm30.ans} |
| 4351 |
\writepuzzle% |
| 4352 |
{765834921}{318279465}{294615378}% |
| 4353 |
{657392814}{823741659}{941568732}% |
| 4354 |
{439157286}{186423597}{572986143}% |
| 4355 |
[SSBL medium 30 solution] |
| 4356 |
\vfill |
| 4357 |
\noindent\begin{minipage}{0.47\linewidth}\begin{center} |
| 4358 |
SM25 (medium solution) \\ |
| 4359 |
\sudoku{sm25.ans} |
| 4360 |
\end{center}\end{minipage} |
| 4361 |
\hfill |
| 4362 |
\begin{minipage}{0.47\linewidth}\begin{center} |
| 4363 |
SM30 (medium solution) \\ |
| 4364 |
\sudoku{sm30.ans} |
| 4365 |
\end{center}\end{minipage} |
| 4366 |
|
| 4367 |
\renewcommand*{\puzzlefile}{tm35.ans} |
| 4368 |
\writepuzzle% |
| 4369 |
{591328746}{674951823}{238674195}% |
| 4370 |
{356297481}{427185369}{819463257}% |
| 4371 |
{985732614}{742516938}{163849572}% |
| 4372 |
[DT2 moderate 35 solution] |
| 4373 |
\renewcommand*{\puzzlefile}{tm40.ans} |
| 4374 |
\writepuzzle% |
| 4375 |
{874136592}{952478136}{316592874}% |
| 4376 |
{631284759}{287915463}{495367281}% |
| 4377 |
{763841925}{548629317}{129753648}% |
| 4378 |
[DT2 moderate 40 solution] |
| 4379 |
\vfill |
| 4380 |
\noindent\begin{minipage}{0.47\linewidth}\begin{center} |
| 4381 |
TM35 (moderate solution) \\ |
| 4382 |
\sudoku{tm35.ans} |
| 4383 |
\end{center}\end{minipage} |
| 4384 |
\hfill |
| 4385 |
\begin{minipage}{0.47\linewidth}\begin{center} |
| 4386 |
TM40 (moderate solution) \\ |
| 4387 |
\sudoku{tm40.ans} |
| 4388 |
\end{center}\end{minipage} |
| 4389 |
|
| 4390 |
\renewcommand*{\puzzlefile}{tm45.ans} |
| 4391 |
\writepuzzle% |
| 4392 |
{716248935}{538769421}{924531786}% |
| 4393 |
{179683542}{652974813}{483152679}% |
| 4394 |
{241896357}{897325164}{365417298}% |
| 4395 |
[DT2 moderate 45 solution] |
| 4396 |
\renewcommand*{\puzzlefile}{tm50.ans} |
| 4397 |
\writepuzzle% |
| 4398 |
{751962834}{468375219}{392148756}% |
| 4399 |
{627891345}{143526987}{589437162}% |
| 4400 |
{975613428}{834259671}{216784593}% |
| 4401 |
[DT2 moderate 50 solution] |
| 4402 |
\vfill |
| 4403 |
\noindent\begin{minipage}{0.47\linewidth}\begin{center} |
| 4404 |
TM45 (moderate solution) \\ |
| 4405 |
\sudoku{tm45.ans} |
| 4406 |
\end{center}\end{minipage} |
| 4407 |
\hfill |
| 4408 |
\begin{minipage}{0.47\linewidth}\begin{center} |
| 4409 |
TM50 (moderate solution) \\ |
| 4410 |
\sudoku{tm50.ans} |
| 4411 |
\end{center}\end{minipage} |
| 4412 |
|
| 4413 |
\renewcommand*{\puzzlefile}{tm55.ans} |
| 4414 |
\writepuzzle% |
| 4415 |
{731946528}{245138679}{968572143}% |
| 4416 |
{614729385}{572813964}{893465712}% |
| 4417 |
{159684237}{426357891}{387291456}% |
| 4418 |
[DT2 moderate 55 solution] |
| 4419 |
\renewcommand*{\puzzlefile}{tm60.ans} |
| 4420 |
\writepuzzle% |
| 4421 |
{734198562}{156324798}{982567431}% |
| 4422 |
{813752649}{465983217}{279416853}% |
| 4423 |
{341875926}{697241385}{528639174}% |
| 4424 |
[DT2 moderate 60 solution] |
| 4425 |
\vfill |
| 4426 |
\noindent\begin{minipage}{0.47\linewidth}\begin{center} |
| 4427 |
TM55 (moderate solution) \\ |
| 4428 |
\sudoku{tm55.ans} |
| 4429 |
\end{center}\end{minipage} |
| 4430 |
\hfill |
| 4431 |
\begin{minipage}{0.47\linewidth}\begin{center} |
| 4432 |
TM60 (moderate solution) \\ |
| 4433 |
\sudoku{tm60.ans} |
| 4434 |
\end{center}\end{minipage} |
| 4435 |
|
| 4436 |
\renewcommand*{\puzzlefile}{st0914.ans} |
| 4437 |
\writepuzzle% |
| 4438 |
{567293184}{298461537}{413578692}% |
| 4439 |
{321759468}{649812753}{785634921}% |
| 4440 |
{936127845}{872945316}{154386279}% |
| 4441 |
[Seattle Times 2005/09/14 2 star solution] |
| 4442 |
\renewcommand*{\puzzlefile}{st0207.ans} |
| 4443 |
\writepuzzle% |
| 4444 |
{872351946}{561849273}{934672581}% |
| 4445 |
{759283164}{628514397}{413967852}% |
| 4446 |
{285436719}{196725438}{347198625}% |
| 4447 |
[Seattle Times 2005/02/07 2 star solution] |
| 4448 |
\vfill |
| 4449 |
\noindent\begin{minipage}{0.47\linewidth}\begin{center} |
| 4450 |
ST0914 (2 star solution) \\ |
| 4451 |
\sudoku{st0914.ans} |
| 4452 |
\end{center}\end{minipage} |
| 4453 |
\hfill |
| 4454 |
\begin{minipage}{0.47\linewidth}\begin{center} |
| 4455 |
ST0207 (2 star solution) \\ |
| 4456 |
\sudoku{st0207.ans} |
| 4457 |
\end{center}\end{minipage} |
| 4458 |
|
| 4459 |
\renewcommand*{\puzzlefile}{cs4.ans} |
| 4460 |
\writepuzzle% |
| 4461 |
{123465978}{456798312}{789132645}% |
| 4462 |
{891243756}{234576189}{567819423}% |
| 4463 |
{912354867}{678921534}{345687291}% |
| 4464 |
[CreateSudoku 4 (level 4) solution] |
| 4465 |
\renewcommand*{\puzzlefile}{cs5.ans} |
| 4466 |
\writepuzzle% |
| 4467 |
{231654978}{564987312}{897321645}% |
| 4468 |
{918432756}{675198423}{342765189}% |
| 4469 |
{786219534}{453876291}{129543867}% |
| 4470 |
[CreateSudoku 5 (level 4) solution] |
| 4471 |
\vfill |
| 4472 |
\noindent\begin{minipage}{0.47\linewidth}\begin{center} |
| 4473 |
CS4 (level 8 solution) \\ |
| 4474 |
\sudoku{cs4.ans} |
| 4475 |
\end{center}\end{minipage} |
| 4476 |
\hfill |
| 4477 |
\begin{minipage}{0.47\linewidth}\begin{center} |
| 4478 |
CS5 (level 8 solution) \\ |
| 4479 |
\sudoku{cs5.ans} |
| 4480 |
\end{center}\end{minipage} |
| 4481 |
|
| 4482 |
\renewcommand*{\puzzlefile}{cs6.ans} |
| 4483 |
\writepuzzle% |
| 4484 |
{312654978}{645987312}{978321645}% |
| 4485 |
{756198423}{423765189}{189432756}% |
| 4486 |
{534876291}{291543867}{867219534}% |
| 4487 |
[CreateSudoku 6 (level 4) solution] |
| 4488 |
\renewcommand*{\puzzlefile}{sh5.ans} |
| 4489 |
\writepuzzle% |
| 4490 |
{269175438}{471832965}{583694217}% |
| 4491 |
{715426389}{894317526}{326958741}% |
| 4492 |
{942561873}{138749652}{657283194}% |
| 4493 |
[SSBL hard 5 solution] |
| 4494 |
\vfill |
| 4495 |
\noindent\begin{minipage}{0.47\linewidth}\begin{center} |
| 4496 |
CS6 (level 4 solution) \\ |
| 4497 |
\sudoku{cs6.ans} |
| 4498 |
\end{center}\end{minipage} |
| 4499 |
\hfill |
| 4500 |
\begin{minipage}{0.47\linewidth}\begin{center} |
| 4501 |
SH5 (hard solution) \\ |
| 4502 |
\sudoku{sh5.ans} |
| 4503 |
\end{center}\end{minipage} |
| 4504 |
|
| 4505 |
\renewcommand*{\puzzlefile}{sh10.ans} |
| 4506 |
\writepuzzle% |
| 4507 |
{437921865}{156837492}{289456137}% |
| 4508 |
{598163274}{374295681}{621748953}% |
| 4509 |
{713682549}{845319726}{962574318}% |
| 4510 |
[SSBL hard 10 solution] |
| 4511 |
\renewcommand*{\puzzlefile}{sh15.ans} |
| 4512 |
\writepuzzle% |
| 4513 |
{216935847}{478261359}{395478261}% |
| 4514 |
{761392584}{952846713}{843157926}% |
| 4515 |
{124783695}{539624178}{687519432}% |
| 4516 |
[SSBL hard 15 solution] |
| 4517 |
\vfill |
| 4518 |
\noindent\begin{minipage}{0.47\linewidth}\begin{center} |
| 4519 |
SH10 (hard solution) \\ |
| 4520 |
\sudoku{sh10.ans} |
| 4521 |
\end{center}\end{minipage} |
| 4522 |
\hfill |
| 4523 |
\begin{minipage}{0.47\linewidth}\begin{center} |
| 4524 |
SH15 (hard solution) \\ |
| 4525 |
\sudoku{sh15.ans} |
| 4526 |
\end{center}\end{minipage} |
| 4527 |
|
| 4528 |
\renewcommand*{\puzzlefile}{sh20.ans} |
| 4529 |
\writepuzzle% |
| 4530 |
{468271935}{925438671}{713695284}% |
| 4531 |
{154762893}{832519467}{679384512}% |
| 4532 |
{587943126}{296157348}{341826759}% |
| 4533 |
[SSBL hard 20 solution] |
| 4534 |
\renewcommand*{\puzzlefile}{sh25.ans} |
| 4535 |
\writepuzzle% |
| 4536 |
{439561728}{167238459}{852497613}% |
| 4537 |
{286953174}{794816532}{513724986}% |
| 4538 |
{348179265}{621345897}{975682341}% |
| 4539 |
[SSBL hard 25 solution] |
| 4540 |
\vfill |
| 4541 |
\noindent\begin{minipage}{0.47\linewidth}\begin{center} |
| 4542 |
SH20 (hard solution) \\ |
| 4543 |
\sudoku{sh20.ans} |
| 4544 |
\end{center}\end{minipage} |
| 4545 |
\hfill |
| 4546 |
\begin{minipage}{0.47\linewidth}\begin{center} |
| 4547 |
SH25 (hard solution) \\ |
| 4548 |
\sudoku{sh25.ans} |
| 4549 |
\end{center}\end{minipage} |
| 4550 |
|
| 4551 |
\renewcommand*{\puzzlefile}{sh30.ans} |
| 4552 |
\writepuzzle% |
| 4553 |
{461258793}{253917846}{789463152}% |
| 4554 |
{346789521}{572146389}{918325674}% |
| 4555 |
{894671235}{635892417}{127534968}% |
| 4556 |
[SSBL hard 30 solution] |
| 4557 |
\renewcommand*{\puzzlefile}{tt100.ans} |
| 4558 |
\writepuzzle% |
| 4559 |
{513896427}{742315698}{968742531}% |
| 4560 |
{154289376}{376154289}{289637154}% |
| 4561 |
{891563742}{425971863}{637428915}% |
| 4562 |
[DT2 tough 100 solution] |
| 4563 |
\vfill |
| 4564 |
\noindent\begin{minipage}{0.47\linewidth}\begin{center} |
| 4565 |
SH30 (hard solution) \\ |
| 4566 |
\sudoku{sh30.ans} |
| 4567 |
\end{center}\end{minipage} |
| 4568 |
\hfill |
| 4569 |
\begin{minipage}{0.47\linewidth}\begin{center} |
| 4570 |
TT100 (tough solution) \\ |
| 4571 |
\sudoku{tt100.ans} |
| 4572 |
\end{center}\end{minipage} |
| 4573 |
|
| 4574 |
\renewcommand*{\puzzlefile}{tt105.ans} |
| 4575 |
\writepuzzle% |
| 4576 |
{925378146}{681254793}{734916582}% |
| 4577 |
{256739418}{178462359}{349581267}% |
| 4578 |
{597843621}{462197835}{813625974}% |
| 4579 |
[DT2 tough 105 solution] |
| 4580 |
\renewcommand*{\puzzlefile}{tt110.ans} |
| 4581 |
\writepuzzle% |
| 4582 |
{379412586}{648539217}{125687349}% |
| 4583 |
{936825174}{214763958}{857194632}% |
| 4584 |
{492358761}{581276493}{763941825}% |
| 4585 |
[DT2 tough 110 solution] |
| 4586 |
\vfill |
| 4587 |
\noindent\begin{minipage}{0.47\linewidth}\begin{center} |
| 4588 |
TT105 (tough solution) \\ |
| 4589 |
\sudoku{tt105.ans} |
| 4590 |
\end{center}\end{minipage} |
| 4591 |
\hfill |
| 4592 |
\begin{minipage}{0.47\linewidth}\begin{center} |
| 4593 |
TT110 (tough solution) \\ |
| 4594 |
\sudoku{tt110.ans} |
| 4595 |
\end{center}\end{minipage} |
| 4596 |
|
| 4597 |
\renewcommand*{\puzzlefile}{tt115.ans} |
| 4598 |
\writepuzzle% |
| 4599 |
{432758196}{196243587}{758169423}% |
| 4600 |
{945682371}{263571849}{871934265}% |
| 4601 |
{329416758}{584397612}{617825934}% |
| 4602 |
[DT2 tough 115 solution] |
| 4603 |
\renewcommand*{\puzzlefile}{tt120.ans} |
| 4604 |
\writepuzzle% |
| 4605 |
{968215734}{143679852}{752384619}% |
| 4606 |
{496523178}{537198246}{281746395}% |
| 4607 |
{875961423}{314852967}{629437581}% |
| 4608 |
[DT2 tough 120 solution] |
| 4609 |
\vfill |
| 4610 |
\noindent\begin{minipage}{0.47\linewidth}\begin{center} |
| 4611 |
TT115 (tough solution) \\ |
| 4612 |
\sudoku{tt115.ans} |
| 4613 |
\end{center}\end{minipage} |
| 4614 |
\hfill |
| 4615 |
\begin{minipage}{0.47\linewidth}\begin{center} |
| 4616 |
TT120 (tough solution) \\ |
| 4617 |
\sudoku{tt120.ans} |
| 4618 |
\end{center}\end{minipage} |
| 4619 |
|
| 4620 |
\renewcommand*{\puzzlefile}{st1130.ans} |
| 4621 |
\writepuzzle% |
| 4622 |
{819356247}{576924813}{342817596}% |
| 4623 |
{781563924}{965248371}{423179685}% |
| 4624 |
{658791432}{297435168}{134682759} |
| 4625 |
[Seattle Times 2005/11/30 3 star solution] |
| 4626 |
\renewcommand*{\puzzlefile}{st1207.ans} |
| 4627 |
\writepuzzle% |
| 4628 |
{217483956}{834695712}{659172384}% |
| 4629 |
{798231645}{326954178}{145768239}% |
| 4630 |
{582319467}{971846523}{463527891}% |
| 4631 |
[Seattle Times 2005/12/07 3 star solution] |
| 4632 |
\vfill |
| 4633 |
\noindent\begin{minipage}{0.47\linewidth}\begin{center} |
| 4634 |
ST1130 (3 star solution) \\ |
| 4635 |
\sudoku{st1130.ans} |
| 4636 |
\end{center}\end{minipage} |
| 4637 |
\hfill |
| 4638 |
\begin{minipage}{0.47\linewidth}\begin{center} |
| 4639 |
ST1207 (3 star solution) \\ |
| 4640 |
\sudoku{st1207.ans} |
| 4641 |
\end{center}\end{minipage} |
| 4642 |
|
| 4643 |
\renewcommand*{\puzzlefile}{st1209.ans} |
| 4644 |
\writepuzzle% |
| 4645 |
{839652147}{246781359}{751943268}% |
| 4646 |
{167295483}{592438716}{483167925}% |
| 4647 |
{628319574}{374526891}{915874632}% |
| 4648 |
[Seattle Times 2005/12/09 5 star solution] |
| 4649 |
\renewcommand*{\puzzlefile}{st1221.ans} |
| 4650 |
\writepuzzle% |
| 4651 |
{517863924}{436925178}{298417563}% |
| 4652 |
{174389652}{683251749}{952674381}% |
| 4653 |
{745132896}{369548217}{821796435}% |
| 4654 |
[Seattle Times 2005/12/21 3 star solution] |
| 4655 |
\vfill |
| 4656 |
\noindent\begin{minipage}{0.47\linewidth}\begin{center} |
| 4657 |
ST1209 (5 star solution) \\ |
| 4658 |
\sudoku{st1209.ans} |
| 4659 |
\end{center}\end{minipage} |
| 4660 |
\hfill |
| 4661 |
\begin{minipage}{0.47\linewidth}\begin{center} |
| 4662 |
ST1221 (3 star solution) \\ |
| 4663 |
\sudoku{st1221.ans} |
| 4664 |
\end{center}\end{minipage} |
| 4665 |
|
| 4666 |
\renewcommand*{\puzzlefile}{st1228.ans} |
| 4667 |
\writepuzzle% |
| 4668 |
{673189524}{812654379}{594273186}% |
| 4669 |
{265791843}{341865792}{987342651}% |
| 4670 |
{795416238}{138927465}{426538917}% |
| 4671 |
[Seattle Times 2005/12/28 3 star solution] |
| 4672 |
\renewcommand*{\puzzlefile}{st0126.ans} |
| 4673 |
\writepuzzle% |
| 4674 |
{253698471}{197435286}{864127953}% |
| 4675 |
{416573829}{785912634}{329864517}% |
| 4676 |
{972356148}{638241795}{541789362}% |
| 4677 |
[Seattle Times 2006/01/26 4 star solution] |
| 4678 |
\vfill |
| 4679 |
\noindent\begin{minipage}{0.47\linewidth}\begin{center} |
| 4680 |
ST1228 (3 star solution) \\ |
| 4681 |
\sudoku{st1228.ans} |
| 4682 |
\end{center}\end{minipage} |
| 4683 |
\hfill |
| 4684 |
\begin{minipage}{0.47\linewidth}\begin{center} |
| 4685 |
ST0126 (4 star solution) \\ |
| 4686 |
\sudoku{st0126.ans} |
| 4687 |
\end{center}\end{minipage} |
| 4688 |
|
| 4689 |
\renewcommand*{\puzzlefile}{st0127.ans} |
| 4690 |
\writepuzzle% |
| 4691 |
{253816479}{467395812}{918427536}% |
| 4692 |
{641752398}{892163745}{375948621}% |
| 4693 |
{189534267}{736289154}{524671983}% |
| 4694 |
[Seattle Times 2006/01/27 5 star solution] |
| 4695 |
\renewcommand*{\puzzlefile}{st0204.ans} |
| 4696 |
\writepuzzle% |
| 4697 |
{153427896}{742986513}{869513247}% |
| 4698 |
{375142968}{428369751}{916875432}% |
| 4699 |
{597321684}{681754329}{234698175}% |
| 4700 |
[Seattle Times 2006/02/04 6 star solution] |
| 4701 |
\vfill |
| 4702 |
\noindent\begin{minipage}{0.47\linewidth}\begin{center} |
| 4703 |
ST0127 (5 star solution) \\ |
| 4704 |
\sudoku{st0127.ans} |
| 4705 |
\end{center}\end{minipage} |
| 4706 |
\hfill |
| 4707 |
\begin{minipage}{0.47\linewidth}\begin{center} |
| 4708 |
ST0204 (6 star solution) \\ |
| 4709 |
\sudoku{st0204.ans} |
| 4710 |
\end{center}\end{minipage} |
| 4711 |
|
| 4712 |
\renewcommand*{\puzzlefile}{st0208.ans} |
| 4713 |
\writepuzzle% |
| 4714 |
{213985647}{589674213}{647213859}% |
| 4715 |
{928751364}{361429578}{754836192}% |
| 4716 |
{875192436}{432567981}{196348725}% |
| 4717 |
[Seattle Times 2005/02/08 3 star solution] |
| 4718 |
\renewcommand*{\puzzlefile}{st0209.ans} |
| 4719 |
\writepuzzle% |
| 4720 |
{639587421}{752341698}{841296753}% |
| 4721 |
{584769312}{976123584}{123458976}% |
| 4722 |
{297834165}{318675249}{465912837}% |
| 4723 |
[Seattle Times 2005/02/09 4 star solution] |
| 4724 |
\vfill |
| 4725 |
\noindent\begin{minipage}{0.47\linewidth}\begin{center} |
| 4726 |
ST0208 (3 star solution) \\ |
| 4727 |
\sudoku{st0208.ans} |
| 4728 |
\end{center}\end{minipage} |
| 4729 |
\hfill |
| 4730 |
\begin{minipage}{0.47\linewidth}\begin{center} |
| 4731 |
ST0209 (4 star solution) \\ |
| 4732 |
\sudoku{st0209.ans} |
| 4733 |
\end{center}\end{minipage} |
| 4734 |
|
| 4735 |
|
| 4736 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% bibliography |
| 4737 |
\cleardoublepage |
| 4738 |
|
| 4739 |
\bibliographystyle{alpha} |
| 4740 |
\begingroup |
| 4741 |
\raggedright |
| 4742 |
\begin{thebibliography}{GMSN94A} |
| 4743 |
|
| 4744 |
\bibitem[Mep05]{DT2} |
| 4745 |
Michael Mepham. |
| 4746 |
\emph{The Daily Telegraph Sudoku 2}. |
| 4747 |
\newblock Pan Books, 2005. |
| 4748 |
\newblock ISBN 0-330-44203-3. |
| 4749 |
|
| 4750 |
\bibitem[Wil06]{SUDOKUBUNDLE} |
| 4751 |
Peter Wilson. |
| 4752 |
\emph{The sudoku bundle for displaying, solving and generating |
| 4753 |
Sudoku puzzles}. |
| 4754 |
\newblock February 2006. |
| 4755 |
\newblock (Available from CTAN in \url{macros/latex/contrib/sudokubundle}). |
| 4756 |
|
| 4757 |
\bibitem[SOL]{SOL} |
| 4758 |
\emph{Sudoku Online: Home of the Sudokulist}. |
| 4759 |
\newblock \url{http://www.sudoku.org.uk} |
| 4760 |
|
| 4761 |
\bibitem[SSBL]{SSBL} |
| 4762 |
\emph{Sudoku Solver ... by logic}. |
| 4763 |
\newblock \url{http://www.sudokusolver.co.uk} |
| 4764 |
|
| 4765 |
\end{thebibliography} |
| 4766 |
\endgroup |
| 4767 |
|
| 4768 |
\end{document} |
| 4769 |
|
| 4770 |
%</examples> |
| 4771 |
% \end{macrocode} |
| 4772 |
% |
| 4773 |
% \Finale |
| 4774 |
% |
| 4775 |
% |
| 4776 |
\endinput |
| 4777 |
|
| 4778 |
%% \CharacterTable |
| 4779 |
%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z |
| 4780 |
%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z |
| 4781 |
%% Digits \0\1\2\3\4\5\6\7\8\9 |
| 4782 |
%% Exclamation \! Double quote \" Hash (number) \# |
| 4783 |
%% Dollar \$ Percent \% Ampersand \& |
| 4784 |
%% Acute accent \' Left paren \( Right paren \) |
| 4785 |
%% Asterisk \* Plus \+ Comma \, |
| 4786 |
%% Minus \- Point \. Solidus \/ |
| 4787 |
%% Colon \: Semicolon \; Less than \< |
| 4788 |
%% Equals \= Greater than \> Question mark \? |
| 4789 |
%% Commercial at \@ Left bracket \[ Backslash \\ |
| 4790 |
%% Right bracket \] Circumflex \^ Underscore \_ |
| 4791 |
%% Grave accent \` Left brace \{ Vertical bar \| |
| 4792 |
%% Right brace \} Tilde \~} |
| 4793 |
|
| 4794 |
|