;;; compiled by eric@geech.gnu.ai.mit.edu on Fri Apr  2 11:48:08 1993
;;; from file /gd/gnu/emacs/19.0/lisp/mpuz.el
;;; emacs version 19.0.509.
;;; bytecomp version FSF 2.08
;;; optimization is on.

(random t)
(fset 'mpuz-random #[(n) " \n\"W \n[\n" [% random n 0] 4 "\
Return a random integer between 0 and N - 1 inclusive."])
(defvar mpuz-silent nil "\
*Set this to T if you don't want dings on inputs.")
(fset 'mpuz-ding #[nil " !" [mpuz-silent ding t] 2 "\
Dings, unless global variable `mpuz-silent' forbids it."])
(byte-code "! " [boundp mpuz-mode-hook nil] 2)
(defvar mpuz-mode-map nil "\
Local keymap to use in Mult Puzzle.")
(byte-code "  ######################" [mpuz-mode-map make-sparse-keymap define-key "a" mpuz-try-letter "b" "c" "d" "e" "f" "g" "h" "i" "j" "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "" mpuz-offer-abort "?" describe-mode] 4)
(fset 'mpuz-mode #[nil "!!" [mpuz-mode major-mode "Mult Puzzle" mode-name use-local-map mpuz-mode-map run-hooks mpuz-mode-hook] 2 "\
Multiplication puzzle mode.

You have to guess which letters stand for which digits in the
multiplication displayed inside the `*Mult Puzzle*' buffer.

You may enter a guess for a letter's value by typing first the letter,
then the digit.  Thus, to guess that A=3, type A 3.

To leave the game to do other editing work, just switch buffers.
Then you may resume the game with M-x mpuz.
You may abort a game by typing \\<mpuz-mode-map>\\[mpuz-offer-abort]." nil])
(defvar mpuz-nb-errors 0 "\
Number of errors made in current game.")
(defvar mpuz-nb-completed-games 0 "\
Number of games completed.")
(defvar mpuz-nb-cumulated-errors 0 "\
Number of errors made in previous games.")
(defvar mpuz-in-progress nil "\
True if a game is currently in progress.")
(defvar mpuz-found-digits (make-vector 10 nil) "\
A vector recording which digits have been decrypted.")
(fset (quote mpuz-digit-solved-p) (quote (macro . #[(digit) "\nE" [aref mpuz-found-digits digit] 3])))
(defvar mpuz-digit-to-letter (make-vector 10 0) "\
A permutation from [0..9] to [0..9].")
(defvar mpuz-letter-to-digit (make-vector 10 0) "\
The inverse of mpuz-digit-to-letter.")
(byte-code "MM" [mpuz-to-digit (macro . #[(letter) "\nE" [aref mpuz-letter-to-digit letter] 3]) mpuz-to-letter (macro . #[(digit) "\nE" [aref mpuz-digit-to-letter digit] 3])] 2)
(fset 'mpuz-build-random-perm #[nil "&\nC !8\"SII +" [list 0 1 2 3 4 5 6 7 8 9 10 nil elem index letters mpuz-random delq mpuz-digit-to-letter mpuz-letter-to-digit] 11 "\
Initialize puzzle coding with a random permutation."])
(defvar mpuz-board (make-vector 10 nil) "\
The board associates ot any digit the list of squares where it appears.")
(fset 'mpuz-put-digit-on-board #[(number square) "	\"		HBI" [% number 10 mpuz-board square] 5 "\
Put (last digit of) NUMBER on SQUARE of the puzzle board."])
(fset 'mpuz-check-all-solved #[nil "" [found (byte-code "	TV 	H 	H \" )ȇ" [-1 digit 10 mpuz-found-digits mpuz-board throw found nil t] 3)] 2 "\
Check whether all digits have been solved. Return t if yes."])
(fset 'mpuz-random-puzzle #[nil " \n\"É!!\"\"\"\"\"W W \"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"-" [mpuz-build-random-perm fillarray mpuz-board nil E D C B A mpuz-random 1000 100 * % 10 / mpuz-put-digit-on-board (2 . 9) (2 . 7) (2 . 5) (4 . 9) (4 . 7) (6 . 9) (6 . 7) (6 . 5) (6 . 3) (8 . 7) (8 . 5) (8 . 3) (8 . 1) (10 . 9) (10 . 7) (10 . 5) (10 . 3) 10000 (10 . 1)] 5 "\
Draw random values to be multiplied in a puzzle."])
(defconst mpuz-framework "\n     . . .\n                   Number of errors (this game): 0\n    x  . .\n   -------\n   . . . .\n                        Number of completed games: 0\n . . . .\n ---------              Average number of errors: 0.00\n . . . . ." "\
The general picture of the puzzle screen, as a string.")
(fset 'mpuz-create-buffer #[nil "!\nq c   *\n)" [get-buffer-create "*Mult Puzzle*" buff nil buffer-read-only erase-buffer mpuz-framework mpuz-paint-board mpuz-paint-errors mpuz-paint-statistics] 2 "\
Create (or recreate) the puzzle buffer. Return it."])
(fset 'mpuz-paint-errors #[nil " !! 	!c)" [mpuz-switch-to-window nil buffer-read-only goto-line 3 move-to-column 49 mpuz-delete-line prin1-to-string mpuz-nb-errors] 2 "\
Paint error count on the puzzle screen."])
(fset 'mpuz-paint-statistics #[nil "U\n  \"\\\\!\"\"	!! !c!! \"	\"	\"$c+" [mpuz-nb-completed-games 0 / * mpuz-nb-cumulated-errors 200 mean % 100 frac-part nil buffer-read-only goto-line 7 move-to-column 51 mpuz-delete-line prin1-to-string 9 50 format "%d.%d%d" 10] 7 "\
Paint statistics about previous games on the puzzle screen."])
(fset 'mpuz-paint-board #[nil " \nTV \nH! )eb" [mpuz-switch-to-window -1 letter 10 mpuz-paint-digit mpuz-letter-to-digit] 3 "\
Paint board situation on the puzzle screen."])
(fset 'mpuz-paint-digit #[(digit) "	H 	\\ 	H\\	H	D @@!@A!c!!A  +" [mpuz-found-digits digit 48 mpuz-digit-to-letter 65 mpuz-board square-l char nil buffer-read-only goto-line move-to-column delete-char 1 backward-char] 4 "\
Paint all occurrences of DIGIT on the puzzle board."])
(fset 'mpuz-delete-line #[nil "`fU? !  " [10 delete-char 1] 2 "\
Clear from point to next newline."])
(fset 'mpuz-get-buffer #[nil "!" [get-buffer "*Mult Puzzle*"] 2 "\
Get the puzzle buffer if it exists."])
(fset 'mpuz-switch-to-window #[nil " \n  	!   )" [mpuz-get-buffer buff mpuz-create-buffer switch-to-buffer buffer-read-only toggle-read-only mpuz-mode] 3 "\
Find or create the Mult-Puzzle buffer, and display it."])
(fset 'mpuz-abort-game #[nil "!\" 	 	!)" [message "Mult Puzzle aborted." nil mpuz-in-progress 0 mpuz-nb-errors fillarray mpuz-board mpuz-get-buffer buff kill-buffer] 4 "\
Abort any puzzle in progess."])
(fset 'mpuz-start-new-game #[nil "!\"     " [message "Here we go..." 0 mpuz-nb-errors t mpuz-in-progress fillarray mpuz-found-digits nil mpuz-random-puzzle mpuz-switch-to-window mpuz-paint-board mpuz-paint-errors mpuz-ask-for-try] 3 "\
Start a new puzzle."])
(fset 'mpuz-offer-new-game #[nil "!	  !" [y-or-n-p "Start a new game " mpuz-start-new-game message "OK. I won't."] 2 "\
Ask if user wants to start a new puzzle."])
(fset 'mpuz #[nil " 	\n   " [mpuz-switch-to-window mpuz-in-progress mpuz-offer-abort mpuz-start-new-game] 1 "\
Multiplication puzzle with GNU Emacs." nil])
(fset 'mpuz-offer-abort #[nil "!	   " [y-or-n-p "Abort game " mpuz-abort-game mpuz-ask-for-try] 2 "\
Ask if user wants to abort current puzzle." nil])
(fset 'mpuz-ask-for-try #[nil "!" [message "Your try ?"] 2 "\
Ask for user proposal in puzzle."])
(fset 'mpuz-try-letter #[nil "c !ZH\nH& \"a H4 \"a \" =E  #VW W] !a \", " [mpuz-in-progress nil message digit-char digit letter-char upcase last-command-char mpuz-letter-to-digit 65 mpuz-found-digits "%c already solved." mpuz-board "%c does not appear." "%c = " read-char 61 "%c = %c" 57 48 ding t mpuz-try-proposal mpuz-offer-new-game] 5 "\
Propose a digit for a letter in puzzle." nil])
(fset 'mpuz-try-proposal #[(letter-char digit-char) "ZZ\nHH !B U2 # !B # T +" [letter-char 65 letter digit-char 48 digit mpuz-letter-to-digit correct-digit mpuz-found-digits message "%c has already been found." "%c = %c correct !" mpuz-ding mpuz-correct-guess "%c = %c incorrect !" mpuz-nb-errors mpuz-paint-errors] 4 "\
Propose LETTER-CHAR as code for DIGIT-CHAR."])
(fset 'mpuz-correct-guess #[(digit) "	I	!   " [mpuz-found-digits digit t mpuz-paint-digit mpuz-check-all-solved mpuz-close-game] 3 "\
Handle correct guessing of DIGIT."])
(fset 'mpuz-close-game #[nil "\n\\T  !!P!'  * !)" [nil mpuz-in-progress mpuz-nb-cumulated-errors mpuz-nb-errors mpuz-nb-completed-games mpuz-paint-statistics mpuz-congratulate message sit-for 4 y-or-n-p "  Start a new game " mpuz-start-new-game "Good Bye !"] 3 "\
Housecleaning when puzzle has been solved."])
(fset 'mpuz-congratulate #[nil "\nU Ă\\ \nU Ƃ\\ \nU! Ȃ\\ \nU+ ʂ\\ \nU5 ̂\\ \nYE \nWE ς\\ \nYU \nWU т\\ \nY\\ #" [format "Puzzle solved with %d errors. %s" mpuz-nb-errors 0 "That's perfect !" 1 "That's very good !" 2 "That's good." 3 "That's not bad." 4 "That's not too bad..." 5 10 "That's bad !" 15 "That's awful." "That's not serious."] 5 "\
Build a congratulation message when puzzle is solved."])
(fset 'mpuz-show-solution #[nil " TV  H	 \nB	 \n\"*" [mpuz-switch-to-window nil list digit -1 10 mpuz-found-digits mapcar mpuz-correct-guess] 3 "\
Display solution for debugging purposes." nil])
