File: sudoku.html

package info (click to toggle)
sudoku 1.0.5-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 344 kB
  • ctags: 373
  • sloc: ansic: 3,483; makefile: 49
file content (275 lines) | stat: -rwxr-xr-x 11,398 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
<HTML>
<HEAD>
<TITLE>Sudoku Manual Page</TITLE>
</HEAD>
<BODY>
<PRE>

</PRE>
<H2>SYNOPSIS</H2><PRE>
       (play the game)
	      <B>sudoku</B> [<I>options</I>] ...  [<I>&lt;filename&gt;</I>]

       (generate boards)
	      <B>sudoku</B> <B>-g</B> [<I>&lt;num&gt;</I>] [<I>options</I>] ...

       (solve boards)
	      <B>sudoku</B> <B>-v</B> [<I>options</I>] ...

       (calculate statistics)
	      <B>sudoku</B> <B>-s</B> [<I>options</I>] ...


</PRE>
<H2>DESCRIPTION</H2><PRE>
       The  <B>sudoku</B> board game is played on a 9x9 grid, divided into rows, col-
       umns, and 9 blocks of 3x3 squares. The objective is to fill  the  empty
       squares	with  the digits 1-9, so that each row, column, and block con-
       tains each of the digits 1-9 (and hence, it is  not  possible  for  any
       digit to appear twice in the same row, column or block).


</PRE>
<H2>EXAMPLE</H2><PRE>
       Consider the following board, and the squares marked `<I>a</I>'-`<I>h</I>' and `<I>x</I>':

	 5 . <I>a</I> | 6 <I>b</I> 1 | . . .	     The digits appearing in each of the
	 7 9 . | . . . | <I>c</I> 6 8	     squares `<I>a</I>'-`<I>h</I>' can be uniquely
	 <I>d</I> 3 . | . 8 . | 7 . .	     determined. For example, the value
	-------+-------+-------      at `<I>a</I>' must be 8, since an 8 appears
	 . 5 . | 4 1 <I>e</I> | . . 2	     in the other rows and columns of the
	 . . 1 | <I>f</I> <I>x</I> . | 6 . .	     block. Using similar logic, it must
	 8 . . | . 3 7 | . 4 .	     be true that:
	-------+-------+------- 	  <I>b</I> = 7        <I>f</I> = 8
	 . . 4 | . 9 . | <I>g</I> 2 .		  <I>c</I> = 1        <I>g</I> = 8
	 2 8 <I>h</I> | . . . | . 9 7		  <I>d</I> = 1        <I>h</I> = 5
	 . . . | 5 <I>i</I> 8 | . . 6		  <I>e</I> = 6        <I>i</I> = 2

       In  contrast, it is not possible to uniquely determine the value of `<I>x</I>'
       with the given information - it could take either the value 2 or 5.

       The board now contains the squares:

	 5 . 8 | 6 7 1 | . . .	  It is now possible to determine the values
	 7 9 . | . . . | 1 6 8	  appearing in other empty squares.
	 1 3 . | . 8 . | 7 . .
	-------+-------+-------
	 . 5 . | 4 1 6 | . . 2
	 . . 1 | 8 <I>x</I> . | 6 . .	  &lt;&lt;< the value of <I>x</I> must now be 5.
	 8 . . | . 3 7 | . 4 .
	-------+-------+-------
	 . . 4 | . 9 . | 8 2 .
	 2 8 5 | . . . | . 9 7
	 . . . | 5 2 8 | . . 6

       Repeating this process a few more times reveals the solution:

	 5 4 8 | 6 7 1 | 2 3 9
	 7 9 2 | 3 4 5 | 1 6 8
	 1 3 6 | 9 8 2 | 7 5 4
	-------+-------+-------
	 3 5 7 | 4 1 6 | 9 8 2
	 4 2 1 | 8 5 9 | 6 7 3
	 8 6 9 | 2 3 7 | 5 4 1
	-------+-------+-------
	 6 1 4 | 7 9 3 | 8 2 5
	 2 8 5 | 1 6 4 | 3 9 7
	 9 7 3 | 5 2 8 | 4 1 6


</PRE>
<H2>GAME INTERFACE</H2><PRE>
       The <B>sudoku</B> game has  a  simple  text  interface	(using	the  <B>curses(3)</B>
       library).  The  board  is  displayed in the middle of the screen, along
       with a summary of the allowed key presses.  The	cursor	can  be  moved
       around  the  board  using the arrow keys or the standard <B>vi(1)</B> movement
       keys, and each square (except for the fixed board squares that are ini-
       tially  revealed)  can  be  set to a given digit by pressing the corre-
       sponding number key, or cleared by  pressing  either  the  `<I>0</I>'  or  `<I>.</I>'
       keys.

   <B>Generating</B> <B>a</B> <B>New</B> <B>Board</B>
       A  new  board can be generated at any time by pressing the `<I>n</I>' key, and
       either a <I>precanned</I> or randomly generated board will be  displayed.   If
       the  <B>-n</B>	command line option is set, then only <I>precanned</I> boards will be
       displayed.

   <B>Entering</B> <B>a</B> <B>Custom</B> <B>Board</B>
       A custom board (e.g. found on the internet, or published in  a  newspa-
       per)  can  be entered into the game by first clearing the current board
       (press the `<I>c</I>' key), entering the published squares (using  the	cursor
       motion  keys and entering the appropriate numbers), and then fixing the
       squares by pressing the `<I>f</I>' key. At this  point,  the  entered  squares
       will be fixed (and cannot be changed).

   <B>Hints</B>
       The interactive game provides a simple hint mechanism to provide assis-
       tance in solving the board. It attempts to highlight areas of the board
       where  moves  can  be made. If repeated hints are requested, the system
       starts revealing the digit that can be placed on the board.

       Often the hints can be quite cryptic. For example, consider  the  board
       below:

	   v v v

	   . . 7 | . . <B>9</B> | . . .
	   <B>9</B> . <B>6</B> | 7 <B>4</B> . | . <B>1</B> <B>5</B>
	   . . <B>2</B> | <B>5</B> <B>1</B> . | . . .
	  -------+-------+-------
	&gt;  <B>6</B> . <B>5</B> | . 7 . | . . <B>8</B>  &lt;    <I>The</I> <I>characters</I> <I>&gt;&lt;v^</I> <I>highlight</I> <I>the</I>
	&gt;  . <B>7</B> . | . . . | . <B>3</B> .  &lt;    <I>area</I> <I>of</I> <I>the</I> <I>hint</I>
	&gt;  <B>8</B> . . | . . . | <B>7</B> . <B>6</B>  &lt;
	  -------+-------+-------
	   . . . | . <B>6</B> <B>7</B> | <B>8</B> . .
	   <B>7</B> <B>4</B> . | . <B>5</B> . | <B>9</B> 6 <B>2</B>
	   . 6 . | <B>4</B> . . | . . .

	   ^ ^ ^

       The  system  gives  the hint `<I>try</I> <I>the</I> <I>digit</I> <I>3</I>', but it is certainly not
       obvious, with the revealed squares, where the 3 goes.


</PRE>
<H2>OPTIONS</H2><PRE>
       <B>-c</B><I>&lt;class&gt;</I>
	      Generate a board until it finds a board of the specified class.
	      Supported classes are: very easy, easy, medium, hard, and fiendish.

       <B>-d</B>     Describe the moves needed to solve the board. Can only  be  used
	      with the <B>-v</B> option for solving <I>precanned</I> boards.

       <B>-f</B><I>&lt;format&gt;</I>
	      Set output format. The supported formats are:
		<B>standard</B>  Default text format; <B>std</B> is a shortcut.
		<B>compact</B>   Compact text format.
		<B>csv</B>	  Comma separated values, suitable for importing
			  into a spreadsheet.
		<B>postscriptps</B> is a shortcut.
		<B>html</B>	  Simple HTML.

       <B>-g</B><I>[&lt;num&gt;]</I>
	      Generate	<I>&lt;num&gt;</I>  boards  (or just 1 board, if not specified) and
	      write them to standard output.

       <B>-n</B>     No random boards generated in the interactive game. Requires the
	      optional file of <I>precanned</I> boards to be specified.

       <B>-r</B>     Run in restricted mode, disallowing any games to be saved.

       <B>-s</B>     Calculate  statistics  for  the <I>precanned</I> boards, and attempt to
	      classify the difficulty of solving the boards. Can be used  with
	      the <B>-v</B> option.

       <B>-t</B><I>&lt;filename&gt;</I>
	      Set  the template file. The file set on the command line will be
	      used instead of the default template file.

       <B>-v</B>     Solve <I>precanned</I> boards, writing the solution to standard output.

       <I>&lt;filename&gt;</I>
	      Name of the optional file containing <I>precanned</I> boards.

       <B>-w</B>     Write <I>default template</I> to the working directory if it doesn't
	      exist yet.


</PRE>
<H2>ENVIRONMENT</H2><PRE>
       No environment variables are used directly by the <B>sudoku</B> program.


</PRE>
<H2>FILES</H2><PRE>
       <B>/usr/share/sudoku/template</B>
	      Template file for generating new sudoku boards.

       <B>/usr/share/sudoku/precanned</B>
	      Optional file, containing `precanned' sudoku boards.


</PRE>
<H2>FILE FORMATS</H2><PRE>
   <B>/usr/share/sudoku/template</B>
       The  template  file  contains  a sequence of patterns that are used for
       generating new <B>sudoku</B> boards. Each pattern is started by a line with  a
       leading	`%'  character,  and  consists of 9 lines of 9 characters. The
       character `.' represents a square that  is  initially  blank,  and  the
       character  `*'  represents a square with a digit that is initially dis-
       played.

   <B>Compact</B> <B>text</B> <B>format</B>
       This format is similar to that of the template file, but contains  rep-
       resentations  of  game  boards.	Each board is started by a line with a
       leading `%' character, followed by an optional title for the board that
       is  displayed when the game is played. This is followed by 9 lines of 9
       characters, where the  character  `.'  represents  an  initially  empty
       square,	and  the  characters  `1'-`9'  give the value of a fixed board
       square that is initially displayed. The <B>sudoku</B> program  can  read  pre-
       canned  files  in  this	format, and will write them when the <B>-fcompact</B>
       option is set.

   <B>Standard</B> <B>text</B> <B>format</B>
       This format is very similar to the compact text	format,  but  includes
       additional  characters  to  delimit the blocks in the board. The <B>sudoku</B>
       program can read precanned files in this format,  and  writes  them  by
       default, unless another output format is set by the <B>-f</B> option.

   <B>Comma</B> <B>separated</B> <B>text</B> <B>format</B>
       This  format  is useful for importing <B>sudoku</B> boards into a spreadsheet.
       It represents each board by 9 lines of  comma  separated  fields.  Each
       field  is  blank,  or contains a digit.	The <B>sudoku</B> program cannot read
       precanned files in this format, and writes them when the  <B>-fcsv</B>	option
       is set. Unlike the standard or compact text formats, there are no lines
       separating boards, and hence, it is really only feasible to  store  one
       board per file.

   <B>Postscript</B> <B>format</B>
       This  format  is useful for printing out <B>sudoku</B> boards. The <B>sudoku</B> pro-
       gram cannot read boards stored in this format, and writes them when the
       <B>-fpostscript</B>  option  is  set. Unlike the standard or compact text for-
       mats, it is not possible to store multiple boards in the same file.

   <B>HTML</B> <B>format</B>
       This format is useful for printing out <B>sudoku</B> boards. The  <B>sudoku</B>  pro-
       gram cannot read boards stored in this format, and writes them when the
       <B>-fhtml</B> option is set. Unlike the standard or compact text  formats,  it
       is not possible to store multiple boards in the same file.


</PRE>
<H2>SEE ALSO</H2><PRE>
       There  are  a  large  number of websites dedicated to the <B>sudoku</B> puzzle
       that can be found easily using a search engine.	Some  of  these  sites
       provide	game  boards that can be challenging to solve, and others pro-
       vide strategies for finding moves.


</PRE>
<H2>DIAGNOSTICS</H2><PRE>
       There are limited diagnostics available when an error occurs.


</PRE>
<H2>ACKNOWLEDGEMENTS</H2><PRE>
       Mark Foreman for the HTML output format; Joanna Ferris and Heather  for
       encouraging this endeavour.


</PRE>
<H2>AUTHOR</H2><PRE>
       Michael Kennett (mike@laurasia.com.au)


</PRE>
<H2>COPYRIGHT</H2><PRE>
       This  manual  page, and all associated files, have been placed into the
       public domain by Michael Kennett, July 2005. They may be used  by  any-
       body  for  any  purpose	whatsoever,  however <B>NO</B> <B>WARRANTY</B>, of any sort,
       applies to this work.

</PRE>
<HR/>
</BODY>
</HTML>