Mercurial > emacs
annotate lisp/play/mpuz.el @ 2243:23228edebc59
Fix spacing conventions.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Thu, 18 Mar 1993 10:18:30 +0000 |
parents | d0b19afef0ae |
children | f287613dfc28 |
rev | line source |
---|---|
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
232
diff
changeset
|
1 ;;; mpuz.el --- multiplication puzzle for GNU Emacs |
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
232
diff
changeset
|
2 |
838 | 3 ;;; Copyright (C) 1990 Free Software Foundation, Inc. |
4 | |
791
203c23c9f22c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
659
diff
changeset
|
5 ;; Author: Philippe Schnoebelen <phs@lifia.imag.fr> |
203c23c9f22c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
659
diff
changeset
|
6 ;; Keywords: games |
203c23c9f22c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
659
diff
changeset
|
7 |
142 | 8 ;; This file is part of GNU Emacs. |
9 | |
10 ;; GNU Emacs is distributed in the hope that it will be useful, | |
11 ;; but WITHOUT ANY WARRANTY. No author or distributor | |
12 ;; accepts responsibility to anyone for the consequences of using it | |
13 ;; or for whether it serves any particular purpose or works at all, | |
14 ;; unless he says so in writing. Refer to the GNU Emacs General Public | |
15 ;; License for full details. | |
16 | |
17 ;; Everyone is granted permission to copy, modify and redistribute | |
18 ;; GNU Emacs, but only under the conditions described in the | |
19 ;; GNU Emacs General Public License. A copy of this license is | |
20 ;; supposed to have been given to you along with GNU Emacs so you | |
21 ;; can know your rights and responsibilities. It should be in a | |
22 ;; file named COPYING. Among other things, the copyright notice | |
23 ;; and this notice must be preserved on all copies. | |
24 | |
791
203c23c9f22c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
659
diff
changeset
|
25 ;;; Code: |
203c23c9f22c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
659
diff
changeset
|
26 |
142 | 27 (random t) ; randomize |
28 | |
29 (defun mpuz-random (n) | |
30 "Return a random integer between 0 and N - 1 inclusive." | |
31 (setq n (% (random) n)) | |
32 (if (< n 0) (- n) n)) | |
33 | |
34 (defvar mpuz-silent nil | |
35 "*Set this to T if you don't want dings on inputs.") | |
36 | |
37 (defun mpuz-ding () | |
232 | 38 "Dings, unless global variable `mpuz-silent' forbids it." |
142 | 39 (or mpuz-silent (ding t))) |
40 | |
41 | |
42 ;; Mpuz mode and keymaps | |
43 ;;---------------------- | |
44 (defvar mpuz-mode-hook nil) | |
45 | |
46 (defvar mpuz-mode-map nil | |
47 "Local keymap to use in Mult Puzzle.") | |
48 | |
49 (defvar mpuz-read-map nil | |
50 "Local keymap to use (sometimes) in Mult Puzzle.") | |
51 | |
52 (if mpuz-mode-map nil | |
53 (setq mpuz-mode-map (make-sparse-keymap)) | |
54 (define-key mpuz-mode-map "a" 'mpuz-try-letter) | |
55 (define-key mpuz-mode-map "b" 'mpuz-try-letter) | |
56 (define-key mpuz-mode-map "c" 'mpuz-try-letter) | |
57 (define-key mpuz-mode-map "d" 'mpuz-try-letter) | |
58 (define-key mpuz-mode-map "e" 'mpuz-try-letter) | |
59 (define-key mpuz-mode-map "f" 'mpuz-try-letter) | |
60 (define-key mpuz-mode-map "g" 'mpuz-try-letter) | |
61 (define-key mpuz-mode-map "h" 'mpuz-try-letter) | |
62 (define-key mpuz-mode-map "i" 'mpuz-try-letter) | |
63 (define-key mpuz-mode-map "j" 'mpuz-try-letter) | |
64 (define-key mpuz-mode-map "A" 'mpuz-try-letter) | |
65 (define-key mpuz-mode-map "B" 'mpuz-try-letter) | |
66 (define-key mpuz-mode-map "C" 'mpuz-try-letter) | |
67 (define-key mpuz-mode-map "D" 'mpuz-try-letter) | |
68 (define-key mpuz-mode-map "E" 'mpuz-try-letter) | |
69 (define-key mpuz-mode-map "F" 'mpuz-try-letter) | |
70 (define-key mpuz-mode-map "G" 'mpuz-try-letter) | |
71 (define-key mpuz-mode-map "H" 'mpuz-try-letter) | |
72 (define-key mpuz-mode-map "I" 'mpuz-try-letter) | |
73 (define-key mpuz-mode-map "J" 'mpuz-try-letter) | |
74 (define-key mpuz-mode-map "\C-g" 'mpuz-offer-abort) | |
75 (define-key mpuz-mode-map "?" 'describe-mode)) | |
76 | |
77 (if mpuz-read-map nil | |
78 (setq mpuz-read-map (make-keymap)) | |
1217
d0b19afef0ae
Fix setup of mpuz-read-map not to depend on keymap format.
Richard M. Stallman <rms@gnu.org>
parents:
838
diff
changeset
|
79 (let ((i 0)) |
d0b19afef0ae
Fix setup of mpuz-read-map not to depend on keymap format.
Richard M. Stallman <rms@gnu.org>
parents:
838
diff
changeset
|
80 (while (< i (length mpuz-read-map)) |
d0b19afef0ae
Fix setup of mpuz-read-map not to depend on keymap format.
Richard M. Stallman <rms@gnu.org>
parents:
838
diff
changeset
|
81 (define-key mpuz-read-map (char-to-string i) 'exit-minibuffer) |
d0b19afef0ae
Fix setup of mpuz-read-map not to depend on keymap format.
Richard M. Stallman <rms@gnu.org>
parents:
838
diff
changeset
|
82 (setq i (1+ i))))) |
142 | 83 |
84 (defun mpuz-mode () | |
1217
d0b19afef0ae
Fix setup of mpuz-read-map not to depend on keymap format.
Richard M. Stallman <rms@gnu.org>
parents:
838
diff
changeset
|
85 "Multiplication puzzle mode. |
142 | 86 |
232 | 87 You have to guess which letters stand for which digits in the |
1217
d0b19afef0ae
Fix setup of mpuz-read-map not to depend on keymap format.
Richard M. Stallman <rms@gnu.org>
parents:
838
diff
changeset
|
88 multiplication displayed inside the `*Mult Puzzle*' buffer. |
142 | 89 |
1217
d0b19afef0ae
Fix setup of mpuz-read-map not to depend on keymap format.
Richard M. Stallman <rms@gnu.org>
parents:
838
diff
changeset
|
90 You may enter a guess for a letter's value by typing first the letter, |
d0b19afef0ae
Fix setup of mpuz-read-map not to depend on keymap format.
Richard M. Stallman <rms@gnu.org>
parents:
838
diff
changeset
|
91 then the digit. Thus, to guess that A=3, type A 3. |
142 | 92 |
1217
d0b19afef0ae
Fix setup of mpuz-read-map not to depend on keymap format.
Richard M. Stallman <rms@gnu.org>
parents:
838
diff
changeset
|
93 To leave the game to do other editing work, just switch buffers. |
d0b19afef0ae
Fix setup of mpuz-read-map not to depend on keymap format.
Richard M. Stallman <rms@gnu.org>
parents:
838
diff
changeset
|
94 Then you may resume the game with M-x mpuz. |
d0b19afef0ae
Fix setup of mpuz-read-map not to depend on keymap format.
Richard M. Stallman <rms@gnu.org>
parents:
838
diff
changeset
|
95 You may abort a game by typing \\<mpuz-mode-map>\\[mpuz-offer-abort]." |
142 | 96 (interactive) |
97 (setq major-mode 'mpuz-mode | |
98 mode-name "Mult Puzzle") | |
99 (use-local-map mpuz-mode-map) | |
100 (run-hooks 'mpuz-mode-hook)) | |
101 | |
102 | |
103 ;; Some variables for statistics | |
104 ;;------------------------------ | |
105 (defvar mpuz-nb-errors 0 | |
232 | 106 "Number of errors made in current game.") |
142 | 107 |
108 (defvar mpuz-nb-completed-games 0 | |
232 | 109 "Number of games completed.") |
142 | 110 |
111 (defvar mpuz-nb-cumulated-errors 0 | |
112 "Number of errors made in previous games.") | |
113 | |
114 | |
115 ;; Some variables for game tracking | |
116 ;;--------------------------------- | |
117 (defvar mpuz-in-progress nil | |
118 "True if a game is currently in progress.") | |
119 | |
120 (defvar mpuz-found-digits (make-vector 10 nil) | |
121 "A vector recording which digits have been decrypted.") | |
122 | |
123 (defmacro mpuz-digit-solved-p (digit) | |
124 (list 'aref 'mpuz-found-digits digit)) | |
125 | |
126 | |
127 ;; A puzzle uses a permutation of [0..9] into itself. | |
128 ;; We use both the permutation and its inverse. | |
129 ;;--------------------------------------------------- | |
130 (defvar mpuz-digit-to-letter (make-vector 10 0) | |
131 "A permutation from [0..9] to [0..9].") | |
132 | |
133 (defvar mpuz-letter-to-digit (make-vector 10 0) | |
134 "The inverse of mpuz-digit-to-letter.") | |
135 | |
136 (defmacro mpuz-to-digit (letter) | |
137 (list 'aref 'mpuz-letter-to-digit letter)) | |
138 | |
139 (defmacro mpuz-to-letter (digit) | |
140 (list 'aref 'mpuz-digit-to-letter digit)) | |
141 | |
142 (defun mpuz-build-random-perm () | |
143 "Initialize puzzle coding with a random permutation." | |
144 (let ((letters (list 0 1 2 3 4 5 6 7 8 9)) ; new cons cells, because of delq | |
145 (index 10) | |
146 elem) | |
147 (while letters | |
148 (setq elem (nth (mpuz-random index) letters) | |
149 letters (delq elem letters) | |
150 index (1- index)) | |
151 (aset mpuz-digit-to-letter index elem) | |
152 (aset mpuz-letter-to-digit elem index)))) | |
153 | |
154 | |
155 ;; A puzzle also uses a board displaying a mulplication. | |
156 ;; Every digit appears in the board, crypted or not. | |
157 ;;------------------------------------------------------ | |
158 (defvar mpuz-board (make-vector 10 nil) | |
159 "The board associates ot any digit the list of squares where it appears.") | |
160 | |
161 (defun mpuz-put-digit-on-board (number square) | |
162 "Put (last digit of) NUMBER on SQUARE of the puzzle board." | |
163 ;; i.e. push SQUARE on NUMBER square-list | |
164 (setq number (% number 10)) | |
165 (aset mpuz-board number (cons square (aref mpuz-board number)))) | |
166 | |
167 (defun mpuz-check-all-solved () | |
168 "Check whether all digits have been solved. Return t if yes." | |
169 (catch 'found | |
170 (let ((digit -1)) | |
171 (while (> 10 (setq digit (1+ digit))) | |
172 (if (and (not (mpuz-digit-solved-p digit)) ; unsolved | |
173 (aref mpuz-board digit)) ; and appearing in the puzzle ! | |
174 (throw 'found nil)))) | |
175 t)) | |
176 | |
177 | |
178 ;; To build a puzzle, we take two random numbers and multiply them. | |
179 ;; We also take a random permutation for encryption. | |
180 ;; The random numbers are only use to see which digit appears in which square | |
181 ;; of the board. Everything is stored in individual squares. | |
182 ;;--------------------------------------------------------------------------- | |
183 (defun mpuz-random-puzzle () | |
184 "Draw random values to be multiplied in a puzzle." | |
185 (mpuz-build-random-perm) | |
186 (fillarray mpuz-board nil) ; erase the board | |
187 (let (A B C D E) | |
188 ;; A,B,C,D & E, are the five rows of our multiplication. | |
189 ;; Choose random values, discarding uninteresting cases. | |
190 (while (progn | |
191 (setq A (mpuz-random 1000) | |
192 B (mpuz-random 100) | |
193 C (* A (% B 10)) | |
194 D (* A (/ B 10)) | |
195 E (* A B)) | |
196 (or (< C 1000) (< D 1000)))) ; forbid leading zeros in C or D | |
197 ;; Individual digits are now put on their respectives squares. | |
198 ;; [NB: A square is a pair <row,column> of the screen.] | |
199 (mpuz-put-digit-on-board A '(2 . 9)) | |
200 (mpuz-put-digit-on-board (/ A 10) '(2 . 7)) | |
201 (mpuz-put-digit-on-board (/ A 100) '(2 . 5)) | |
202 (mpuz-put-digit-on-board B '(4 . 9)) | |
203 (mpuz-put-digit-on-board (/ B 10) '(4 . 7)) | |
204 (mpuz-put-digit-on-board C '(6 . 9)) | |
205 (mpuz-put-digit-on-board (/ C 10) '(6 . 7)) | |
206 (mpuz-put-digit-on-board (/ C 100) '(6 . 5)) | |
207 (mpuz-put-digit-on-board (/ C 1000) '(6 . 3)) | |
208 (mpuz-put-digit-on-board D '(8 . 7)) | |
209 (mpuz-put-digit-on-board (/ D 10) '(8 . 5)) | |
210 (mpuz-put-digit-on-board (/ D 100) '(8 . 3)) | |
211 (mpuz-put-digit-on-board (/ D 1000) '(8 . 1)) | |
212 (mpuz-put-digit-on-board E '(10 . 9)) | |
213 (mpuz-put-digit-on-board (/ E 10) '(10 . 7)) | |
214 (mpuz-put-digit-on-board (/ E 100) '(10 . 5)) | |
215 (mpuz-put-digit-on-board (/ E 1000) '(10 . 3)) | |
216 (mpuz-put-digit-on-board (/ E 10000) '(10 . 1)))) | |
217 | |
218 ;; Display | |
219 ;;-------- | |
220 (defconst mpuz-framework | |
221 " | |
222 . . . | |
223 Number of errors (this game): 0 | |
224 x . . | |
225 ------- | |
226 . . . . | |
227 Number of completed games: 0 | |
228 . . . . | |
229 --------- Average number of errors: 0.00 | |
230 . . . . ." | |
231 "The general picture of the puzzle screen, as a string.") | |
232 | |
233 (defun mpuz-create-buffer () | |
234 "Create (or recreate) the puzzle buffer. Return it." | |
235 (let ((buff (get-buffer-create "*Mult Puzzle*"))) | |
236 (save-excursion | |
237 (set-buffer buff) | |
238 (let ((buffer-read-only nil)) | |
239 (erase-buffer) | |
240 (insert mpuz-framework) | |
241 (mpuz-paint-board) | |
242 (mpuz-paint-errors) | |
243 (mpuz-paint-statistics))) | |
244 buff)) | |
245 | |
246 (defun mpuz-paint-errors () | |
247 "Paint error count on the puzzle screen." | |
248 (mpuz-switch-to-window) | |
249 (let ((buffer-read-only nil)) | |
250 (goto-line 3) | |
251 (move-to-column 49) | |
252 (mpuz-delete-line) | |
253 (insert (prin1-to-string mpuz-nb-errors)))) | |
254 | |
255 (defun mpuz-paint-statistics () | |
256 "Paint statistics about previous games on the puzzle screen." | |
257 (let* ((mean (if (zerop mpuz-nb-completed-games) 0 | |
258 (/ (+ mpuz-nb-completed-games (* 200 mpuz-nb-cumulated-errors)) | |
259 (* 2 mpuz-nb-completed-games)))) | |
260 (frac-part (% mean 100))) | |
261 (let ((buffer-read-only nil)) | |
262 (goto-line 7) | |
263 (move-to-column 51) | |
264 (mpuz-delete-line) | |
265 (insert (prin1-to-string mpuz-nb-completed-games)) | |
266 (goto-line 9) | |
267 (move-to-column 50) | |
268 (mpuz-delete-line) | |
269 (insert (format "%d.%d%d" (/ mean 100) (/ frac-part 10) (% frac-part 10)))))) | |
270 | |
271 (defun mpuz-paint-board () | |
272 "Paint board situation on the puzzle screen." | |
273 (mpuz-switch-to-window) | |
274 (let ((letter -1)) | |
275 (while (> 10 (setq letter (1+ letter))) | |
276 (mpuz-paint-digit (mpuz-to-digit letter)))) | |
277 (goto-char (point-min))) | |
278 | |
279 (defun mpuz-paint-digit (digit) | |
280 "Paint all occurrences of DIGIT on the puzzle board." | |
281 ;; (mpuz-switch-to-window) | |
282 (let ((char (if (mpuz-digit-solved-p digit) | |
283 (+ digit ?0) | |
284 (+ (mpuz-to-letter digit) ?A))) | |
285 (square-l (aref mpuz-board digit))) | |
286 (let ((buffer-read-only nil)) | |
287 (while square-l | |
288 (goto-line (car (car square-l))) ; line before column ! | |
289 (move-to-column (cdr (car square-l))) | |
290 (insert char) | |
291 (delete-char 1) | |
292 (backward-char 1) | |
293 (setq square-l (cdr square-l)))))) | |
294 | |
295 (defun mpuz-delete-line () | |
296 "Clear from point to next newline." ; & put nothing in the kill ring | |
297 (while (not (= ?\n (char-after (point)))) | |
298 (delete-char 1))) | |
299 | |
300 (defun mpuz-get-buffer () | |
301 "Get the puzzle buffer if it exists." | |
302 (get-buffer "*Mult Puzzle*")) | |
303 | |
304 (defun mpuz-switch-to-window () | |
305 "Find or create the Mult-Puzzle buffer, and display it." | |
306 (let ((buff (mpuz-get-buffer))) | |
307 (or buff (setq buff (mpuz-create-buffer))) | |
308 (switch-to-buffer buff) | |
309 (or buffer-read-only (toggle-read-only)) | |
310 (mpuz-mode))) | |
311 | |
312 | |
313 ;; Game control | |
314 ;;------------- | |
315 (defun mpuz-abort-game () | |
316 "Abort any puzzle in progess." | |
317 (message "Mult Puzzle aborted.") | |
318 (setq mpuz-in-progress nil | |
319 mpuz-nb-errors 0) | |
320 (fillarray mpuz-board nil) | |
321 (let ((buff (mpuz-get-buffer))) | |
322 (if buff (kill-buffer buff)))) | |
323 | |
324 (defun mpuz-start-new-game () | |
325 "Start a new puzzle." | |
326 (message "Here we go...") | |
327 (setq mpuz-nb-errors 0 | |
328 mpuz-in-progress t) | |
329 (fillarray mpuz-found-digits nil) ; initialize mpuz-found-digits | |
330 (mpuz-random-puzzle) | |
331 (mpuz-switch-to-window) | |
332 (mpuz-paint-board) | |
333 (mpuz-paint-errors) | |
334 (mpuz-ask-for-try)) | |
335 | |
336 (defun mpuz-offer-new-game () | |
337 "Ask if user wants to start a new puzzle." | |
338 (if (y-or-n-p "Start a new game ") | |
339 (mpuz-start-new-game) | |
340 (message "OK. I won't."))) | |
341 | |
1217
d0b19afef0ae
Fix setup of mpuz-read-map not to depend on keymap format.
Richard M. Stallman <rms@gnu.org>
parents:
838
diff
changeset
|
342 ;;;###autoload |
d0b19afef0ae
Fix setup of mpuz-read-map not to depend on keymap format.
Richard M. Stallman <rms@gnu.org>
parents:
838
diff
changeset
|
343 (defun mpuz () |
142 | 344 "Multiplication puzzle with GNU Emacs." |
345 ;; Main entry point | |
346 (interactive) | |
347 (mpuz-switch-to-window) | |
348 (if mpuz-in-progress | |
349 (mpuz-offer-abort) | |
350 (mpuz-start-new-game))) | |
351 | |
352 (defun mpuz-offer-abort () | |
353 "Ask if user wants to abort current puzzle." | |
354 (interactive) | |
355 (if (y-or-n-p "Abort game ") | |
356 (mpuz-abort-game) | |
357 (mpuz-ask-for-try))) | |
358 | |
359 (defun mpuz-ask-for-try () | |
360 "Ask for user proposal in puzzle." | |
361 (message "Your try ?")) | |
362 | |
363 (defun mpuz-try-letter () | |
364 "Propose a digit for a letter in puzzle." | |
365 (interactive) | |
366 (if mpuz-in-progress | |
367 (let (letter-char digit digit-char message) | |
368 (setq letter-char (if (or (< last-command-char ?a) | |
369 (> last-command-char ?z)) | |
370 last-command-char | |
371 (- last-command-char 32)) | |
372 digit (mpuz-to-digit (- letter-char ?A))) | |
373 (cond ((mpuz-digit-solved-p digit) | |
374 (message "%c already solved." letter-char)) | |
375 ((null (aref mpuz-board digit)) | |
376 (message "%c does not appear." letter-char)) | |
377 ((progn (setq message (format "%c = " letter-char)) | |
378 ;; <char> has been entered. | |
379 ;; Print "<char> =" and | |
380 ;; read <num> or = <num> | |
381 (read-from-minibuffer message nil mpuz-read-map) | |
382 (if (= last-input-char ?\=) | |
383 (read-from-minibuffer message nil mpuz-read-map)) | |
384 (setq digit-char last-input-char) | |
385 (message "%c = %c" letter-char digit-char) | |
386 (or (> digit-char ?9) (< digit-char ?0))) ; bad input | |
387 (ding t)) | |
388 (t | |
389 (mpuz-try-proposal letter-char digit-char)))) | |
390 (mpuz-offer-new-game))) | |
391 | |
392 (defun mpuz-try-proposal (letter-char digit-char) | |
393 "Propose LETTER-CHAR as code for DIGIT-CHAR." | |
394 (let* ((letter (- letter-char ?A)) | |
395 (digit (- digit-char ?0)) | |
396 (correct-digit (mpuz-to-digit letter))) | |
397 (cond ((mpuz-digit-solved-p correct-digit) | |
398 (message "%c has already been found.")) | |
399 ((= digit correct-digit) | |
400 (message "%c = %c correct !" letter-char digit-char) | |
401 (mpuz-ding) | |
402 (mpuz-correct-guess digit)) | |
403 (t ;;; incorrect guess | |
404 (message "%c = %c incorrect !" letter-char digit-char) | |
405 (mpuz-ding) | |
406 (setq mpuz-nb-errors (1+ mpuz-nb-errors)) | |
407 (mpuz-paint-errors))))) | |
408 | |
409 (defun mpuz-correct-guess (digit) | |
410 "Handle correct guessing of DIGIT." | |
411 (aset mpuz-found-digits digit t) ; Mark digit as solved | |
412 (mpuz-paint-digit digit) ; Repaint it (now as a digit) | |
413 (if (mpuz-check-all-solved) | |
414 (mpuz-close-game))) | |
415 | |
416 (defun mpuz-close-game () | |
417 "Housecleaning when puzzle has been solved." | |
418 (setq mpuz-in-progress nil | |
419 mpuz-nb-cumulated-errors (+ mpuz-nb-cumulated-errors mpuz-nb-errors) | |
420 mpuz-nb-completed-games (1+ mpuz-nb-completed-games)) | |
421 (mpuz-paint-statistics) | |
422 (let ((message (mpuz-congratulate))) | |
423 (message message) | |
424 (sit-for 4) | |
425 (if (y-or-n-p (concat message " Start a new game ")) | |
426 (mpuz-start-new-game) | |
427 (message "Good Bye !")))) | |
428 | |
429 (defun mpuz-congratulate () | |
430 "Build a congratulation message when puzzle is solved." | |
431 (format "Puzzle solved with %d errors. %s" | |
432 mpuz-nb-errors | |
433 (cond ((= mpuz-nb-errors 0) "That's perfect !") | |
434 ((= mpuz-nb-errors 1) "That's very good !") | |
435 ((= mpuz-nb-errors 2) "That's good.") | |
436 ((= mpuz-nb-errors 3) "That's not bad.") | |
437 ((= mpuz-nb-errors 4) "That's not too bad...") | |
438 ((and (>= mpuz-nb-errors 5) | |
439 (< mpuz-nb-errors 10)) "That's bad !") | |
440 ((and (>= mpuz-nb-errors 10) | |
441 (< mpuz-nb-errors 15)) "That's awful.") | |
442 ((>= mpuz-nb-errors 15) "That's not serious.")))) | |
443 | |
444 (defun mpuz-show-solution () | |
445 "Display solution for debugging purposes." | |
446 (interactive) | |
447 (mpuz-switch-to-window) | |
448 (let (digit list) | |
449 (setq digit -1) | |
450 (while (> 10 (setq digit (1+ digit))) | |
451 (or (mpuz-digit-solved-p digit) | |
452 (setq list (cons digit list)))) | |
453 (mapcar 'mpuz-correct-guess list))) | |
454 | |
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
232
diff
changeset
|
455 ;;; mpuz.el ends here |