;ELC ;;; compiled by kwzh@hal.gnu.ai.mit.edu on Mon Apr 17 19:47:27 1995 ;;; from file /gd/gnu/emacs/19.0/lisp/mpuz.el ;;; emacs version 19.28.90.26. ;;; bytecomp version FSF 2.10 ;;; optimization is on. ;;; this file uses opcodes which do not exist in Emacs 18. (if (and (boundp 'emacs-version) (or (and (boundp 'epoch::version) epoch::version) (string-lessp emacs-version "19"))) (error "`/gd/gnu/emacs/19.0/lisp/mpuz.el' was compiled for Emacs 19")) (random t) #@51 *Set this to T if you don't want dings on inputs. (defvar mpuz-silent nil (#$ . -488)) #@57 Dings, unless global variable `mpuz-silent' forbids it. (defalias 'mpuz-ding #[nil "!" [mpuz-silent ding t] 2 (#$ . 581)]) (byte-code "! B‡" [boundp mpuz-mode-hook nil current-load-list] 2) #@37 Local keymap to use in Mult Puzzle. (defvar mpuz-mode-map nil (#$ . 794)) (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) #@454 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-offer-abort]. (defalias 'mpuz-mode #[nil " !!" [mpuz-mode major-mode "Mult Puzzle" mode-name use-local-map mpuz-mode-map run-hooks mpuz-mode-hook] 2 (#$ . 1214) nil]) #@40 Number of errors made in current game. (defvar mpuz-nb-errors 0 (#$ . 1835)) #@28 Number of games completed. (defvar mpuz-nb-completed-games 0 (#$ . 1918)) #@42 Number of errors made in previous games. (defvar mpuz-nb-cumulated-errors 0 (#$ . 1998)) #@42 True if a game is currently in progress. (defvar mpuz-in-progress nil (#$ . 2093)) #@54 A vector recording which digits have been decrypted. (defvar mpuz-found-digits (make-vector 10 nil) (#$ . 2182)) (defalias 'mpuz-digit-solved-p '(macro . #[(digit) "\nE" [aref mpuz-found-digits digit] 3])) #@38 A permutation from [0..9] to [0..9]. (defvar mpuz-digit-to-letter (make-vector 10 0) (#$ . 2397)) #@38 The inverse of mpuz-digit-to-letter. (defvar mpuz-letter-to-digit (make-vector 10 0) (#$ . 2501)) (defalias 'mpuz-to-digit '(macro . #[(letter) "\nE" [aref mpuz-letter-to-digit letter] 3])) (defalias 'mpuz-to-letter '(macro . #[(digit) "\nE" [aref mpuz-digit-to-letter digit] 3])) #@53 Initialize puzzle coding with a random permutation. (defalias 'mpuz-build-random-perm #[nil "ɯ\n\f B !8\f\f\" S  \fI\f I+" [0 1 2 3 4 5 6 7 8 9 10 nil elem index letters random delq mpuz-digit-to-letter mpuz-letter-to-digit] 10 (#$ . 2794)]) #@73 The board associates to any digit the list of squares where it appears. (defvar mpuz-board (make-vector 10 nil) (#$ . 3089)) #@59 Put (last digit of) NUMBER on SQUARE of the puzzle board. (defalias 'mpuz-put-digit-on-board #[(number square) "\n \nHBI" [number 10 mpuz-board square] 5 (#$ . 3220)]) #@61 Check whether all digits have been solved. Return t if yes. (defalias 'mpuz-check-all-solved #[nil "" [found (byte-code " TV H\f H\")ȇ" [-1 digit 10 mpuz-found-digits mpuz-board throw found nil t] 3)] 2 (#$ . 3401)]) #@50 Draw random values to be multiplied in a puzzle. (defalias 'mpuz-random-puzzle #[nil " \n\"É!!̦_̥__W W\"̥\"˥\"\"̥\"\"̥\"˥\"ʥ\" \" ̥\" ˥\" ʥ\"\f\"\f̥\"\f˥\"\fʥ\"\fߥ\"-" [mpuz-build-random-perm fillarray mpuz-board nil E D C B A 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 (#$ . 3651)]) #@56 The general picture of the puzzle screen, as a string. (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 . . . . ." (#$ . 4237)) #@52 Create (or recreate) the puzzle buffer. Return it. (defalias '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 (#$ . 4571)]) #@41 Paint error count on the puzzle screen. (defalias '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 (#$ . 4862)]) #@61 Paint statistics about previous games on the puzzle screen. (defalias 'mpuz-paint-statistics #[nil "U\n\n_\\\\Ŧ!! !c!! \fťӥӦ$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 (#$ . 5108)]) #@45 Paint board situation on the puzzle screen. (defalias 'mpuz-paint-board #[nil " \nTV \nH!)eb" [mpuz-switch-to-window -1 letter 10 mpuz-paint-digit mpuz-letter-to-digit] 3 (#$ . 5494)]) #@53 Paint all occurrences of DIGIT on the puzzle board. (defalias 'mpuz-paint-digit #[(digit) " H\f \\ 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 (#$ . 5701)]) #@35 Clear from point to next newline. (defalias 'mpuz-delete-line #[nil "`fU?!" [10 delete-char 1] 2 (#$ . 6041)]) #@37 Get the puzzle buffer if it exists. (defalias 'mpuz-get-buffer #[nil "!" [get-buffer "*Mult Puzzle*"] 2 (#$ . 6169)]) #@56 Find or create the Mult-Puzzle buffer, and display it. (defalias 'mpuz-switch-to-window #[nil " \n  !\f )" [mpuz-get-buffer buff mpuz-create-buffer switch-to-buffer buffer-read-only toggle-read-only mpuz-mode] 3 (#$ . 6296)]) #@31 Abort any puzzle in progress. (defalias '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 (#$ . 6545)]) #@21 Start a new puzzle. (defalias '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 (#$ . 6787)]) #@42 Ask if user wants to start a new puzzle. (defalias 'mpuz-offer-new-game #[nil "! !" [y-or-n-p "Start a new game " mpuz-start-new-game message "OK. I won't."] 2 (#$ . 7086)]) #@39 Multiplication puzzle with GNU Emacs. (defalias 'mpuz #[nil " \n " [mpuz-switch-to-window mpuz-in-progress mpuz-offer-abort mpuz-start-new-game] 1 (#$ . 7276) nil]) #@44 Ask if user wants to abort current puzzle. (defalias 'mpuz-offer-abort #[nil "! " [y-or-n-p "Abort game " mpuz-abort-game mpuz-ask-for-try] 2 (#$ . 7457) nil]) #@34 Ask for user proposal in puzzle. (defalias 'mpuz-ask-for-try #[nil "!" [message "Your try ?"] 2 (#$ . 7633)]) #@41 Propose a digit for a letter in puzzle. (defalias 'mpuz-try-letter #[nil "b ZH \fH% \"` \fH3 \"` \" =D  # VV W\\!` \", " [mpuz-in-progress nil message digit-char digit letter-char 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 (#$ . 7752) nil]) #@45 Propose LETTER-CHAR as code for DIGIT-CHAR. (defalias 'mpuz-try-proposal #[(letter-char digit-char) "Z Z\nHH!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 (#$ . 8218)]) #@35 Handle correct guessing of DIGIT. (defalias 'mpuz-correct-guess #[(digit) " I !  " [mpuz-found-digits digit t mpuz-paint-digit mpuz-check-all-solved mpuz-close-game] 3 (#$ . 8650)]) #@44 Housecleaning when puzzle has been solved. (defalias 'mpuz-close-game #[nil "\n \\\fT !!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 (#$ . 8849)]) #@55 Build a congratulation message when puzzle is solved. (defalias '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 (#$ . 9206)]) #@42 Display solution for debugging purposes. (defalias 'mpuz-show-solution #[nil "  TV  H \nB \n\"*" [mpuz-switch-to-window nil list digit -1 10 mpuz-found-digits mapcar mpuz-correct-guess] 3 (#$ . 9659) nil])