;ELC ;;; Compiled ;;; in Emacs version 27.1 ;;; with all optimizations. ;;; This file uses dynamic docstrings, first added in Emacs 19.29. ;;; This file does not contain utf-8 non-ASCII characters, ;;; and so can be loaded in Emacs versions earlier than 23. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (byte-code "\300\301\302\303\304\305\306\307&\210\310\311\312\313\314\315\306\301&\210\310\316\317\320\314\321\306\301&\210\310\322\302\323\314\321\306\301&\210\324\325\326\327\306\301%\210\324\330\331\332\306\301%\210\324\333\334\335\306\301%\210\324\336\337\340\306\301%\210\310\341\302\342\314\343\306\301&\207" [custom-declare-group mpuz nil "Multiplication puzzle." :prefix "mpuz-" :group games custom-declare-variable mpuz-silent 'error "Set this to nil if you want dings on inputs.\nThe value t means never ding, and `error' means only ding on wrong input." :type (choice (const :tag "No" nil) (const :tag "Yes" t) (const :tag "If correct" error)) mpuz-solve-when-trivial t "Solve any row that can be trivially calculated from what you've found." boolean mpuz-allow-double-multiplicator "Allow 2nd factors like 33 or 77." custom-declare-face mpuz-unsolved ((default :weight bold) (((class color)) :foreground "red1")) "Face for letters to be solved." mpuz-solved ((default :weight bold) (((class color)) :foreground "green1")) "Face for solved digits." mpuz-trivial ((default :weight bold) (((class color)) :foreground "blue")) "Face for trivial digits solved for you." mpuz-text ((t :inherit variable-pitch)) "Face for text on right." mpuz-mode-hook "Hook to run upon entry to mpuz." hook] 8) #@37 Local keymap to use in Mult Puzzle. (defvar mpuz-mode-map (byte-code "\301 \302\303\304\"\210\305\306\307#\210\305\310\311#\210)\207" [map make-sparse-keymap mapc #[(ch) "\302\303 !\304#\207" [map ch define-key char-to-string mpuz-try-letter] 4] "abcdefghijABCDEFGHIJ" define-key "" mpuz-offer-abort "?" describe-mode] 4) (#$ . 1714)) (defvar mpuz-mode-hook nil) (byte-code "\300\301N\204\f\302\300\301\303#\210\304\305!\204\302\305\306\307#\210\300\207" [mpuz-mode-hook variable-documentation put "Hook run after entering Mult Puzzle mode.\nNo problems result if this variable is not bound.\n`add-hook' automatically binds it. (This is true for all hook variables.)" boundp mpuz-mode-map definition-name mpuz-mode] 4) (defvar mpuz-mode-map (make-sparse-keymap)) (byte-code "\301\302N\204\303\301\302\304\305!#\210\306\307!\204\303\307\310\311#\210\312\313 !\210\307\302N\204-\303\307\302\304\314!#\210\306\300!\204B\303\300\310\311#\210\315\316\300\317\"\210!\210\300\302N\204P\303\300\302\304\320!#\210\303\311\321\317#\207" [mpuz-mode-abbrev-table mpuz-mode-map variable-documentation put purecopy "Keymap for `mpuz-mode'." boundp mpuz-mode-syntax-table definition-name mpuz-mode (lambda (#1=#:def-tmp-var) (defvar mpuz-mode-syntax-table #1#)) make-syntax-table "Syntax table for `mpuz-mode'." (lambda (#1#) (defvar mpuz-mode-abbrev-table #1#)) define-abbrev-table nil "Abbrev table for `mpuz-mode'." derived-mode-parent] 5) #@555 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]. This mode runs the hook `mpuz-mode-hook', as the final or penultimate step during initialization. (defalias 'mpuz-mode #[nil "\306\300!\210\307\310 \210\311\312\313 !\210\314\f!\210 \315)\316\317!\207" [delay-mode-hooks major-mode mode-name mpuz-mode-map mpuz-mode-syntax-table mpuz-mode-abbrev-table make-local-variable t kill-all-local-variables mpuz-mode "Mult Puzzle" use-local-map set-syntax-table 30 run-mode-hooks mpuz-mode-hook local-abbrev-table tab-width] 2 (#$ . 3167) nil]) #@40 Number of errors made in current game. (defvar mpuz-nb-errors 0 (#$ . 4122)) #@28 Number of games completed. (defvar mpuz-nb-completed-games 0 (#$ . 4205)) #@42 Number of errors made in previous games. (defvar mpuz-nb-cumulated-errors 0 (#$ . 4285)) #@42 True if a game is currently in progress. (defvar mpuz-in-progress nil (#$ . 4380)) #@54 A vector recording which digits have been decrypted. (defvar mpuz-found-digits (make-bool-vector 10 nil) (#$ . 4469)) #@59 A vector recording which digits have been solved for you. (defvar mpuz-trivial-digits (make-bool-vector 10 nil) (#$ . 4593)) (defalias 'mpuz-digit-solved-p '(macro . #[(digit) "\301\302\303E\302\304EE\207" [digit or aref mpuz-found-digits mpuz-trivial-digits] 5])) #@38 A permutation from [0..9] to [0..9]. (defvar mpuz-digit-to-letter (make-vector 10 0) (#$ . 4866)) #@40 The inverse of `mpuz-digit-to-letter'. (defvar mpuz-letter-to-digit (make-vector 10 0) (#$ . 4970)) (defalias 'mpuz-to-digit '(macro . #[(letter) "\301\302E\207" [letter aref mpuz-letter-to-digit] 3])) (defalias 'mpuz-to-letter '(macro . #[(digit) "\301\302E\207" [digit aref mpuz-digit-to-letter] 3])) #@53 Initialize puzzle coding with a random permutation. (defalias 'mpuz-build-random-perm #[nil "\305\306\307\310\311\312\313\314\315\316\257\n\317\320\n\2050\321 !\n8\322\n\" S I\210\f I\210\202+\207" [elem index letters mpuz-digit-to-letter mpuz-letter-to-digit 0 1 2 3 4 5 6 7 8 9 10 nil random delq] 10 (#$ . 5281)]) #@73 The board associates to any digit the list of squares where it appears. (defvar mpuz-board (make-vector 10 nil) (#$ . 5617)) #@68 Put (last digit of) NUMBER on ROW and COLUMNS of the puzzle board. (defalias 'mpuz-put-number-on-board #[(number row &rest columns) "\306 \306\211\205) @\f\307\246\f\307\245 \nB HBI\210 A\211\204\n\306+\207" [digit columns column --dolist-tail-- number mpuz-board nil 10 row] 6 (#$ . 5748)]) #@62 Check whether all digits have been solved. Return t if yes. (defalias 'mpuz-check-all-solved #[(&optional row col) "\3062\307\211\211\211\211\211\211\203\374\204\374 \206%\310\311\312\"\f\206.\310\311\313\" \2066\310\314!\206?\310\315!\211\203M \203M\f\204^ \203k\204^ \203k\f\203k\316 \210\317 \210\320\306\321\"\202\371\n\206r\310\322! \206z\310\323!\211\203\215\n\203\215 \204\215\316\314!\202\371 \203\245 \n=\204\245\316\n\203\240\323\202\241\322!\202\371\203\303\f =\204\303\316 \203\271\311\202\272\323 \205\277\313\"\202\371\203\341 \n=\204\341\316\n\203\327\311\202\330\322\n\205\335\312\"\202\371\204\374\f\203\356 \204\366 \203\374\n\203\374\316\315!\204\317 \210\324\325\326\"\210.\3210\207" [squares E D C B2 B1 solved nil mpuz-check-all-solved 4 7 9 10 2 mpuz-solve mpuz-paint-board throw t 8 6 mapc #[(digit) " H\206 \n H?\2055 H\211\2055 \203- \203'  B\f\235\202. \f\236\202.\f\2055\306\307\310\"\207" [mpuz-found-digits digit mpuz-trivial-digits mpuz-board squares row throw solved nil col] 3] [0 1 2 3 4 5 6 7 8 9] A mpuz-solve-when-trivial row] 7 (#$ . 6059)]) #@50 Draw random values to be multiplied in a puzzle. (defalias 'mpuz-random-puzzle #[nil "\306 \210\307\310\"\210 \203\311\312\313!\\\202\314\312\315!\\\316\n\245T\211\312\317 Z!\\\310\211\310\211\f \312\317 Z!\\\211U\203D \2032\n _\n\f_\317_\\\320\n\321\322\323\324%\210\320\f\317_ \\\325\322\323$\210\320\326\322\323\324\327&\210\320\330\323\324\327\331&\210\320\317\322\323\324\327\331&.\207" [mpuz-board mpuz-allow-double-multiplicator A min B1 B2 mpuz-build-random-perm fillarray nil 112 random 888 125 875 999 10 mpuz-put-number-on-board 2 9 7 5 4 6 3 8 1 C D E] 9 (#$ . 7235)]) #@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 . . . . ." (#$ . 7860)) #@53 Create (or recreate) the puzzle buffer. Return it. (defalias 'mpuz-create-buffer #[nil "\304\305!\306\307r\nq\210\310 \210 c\210\311\312\313 #\210\311\314\315 #\210\311\316\317 #\210\320 \210\321 \210\322 \210)\n+\207" [buffer-read-only face buf mpuz-framework get-buffer-create "*Mult Puzzle*" (face mpuz-text) nil erase-buffer set-text-properties 13 42 79 105 128 153 mpuz-paint-board mpuz-paint-errors mpuz-paint-statistics] 4 (#$ . 8140)]) (defalias 'mpuz-paint-number #[(n &optional eol words) "\210\304`\n\206 \305[v\210`|\210 c)\207" [eol buffer-read-only words n nil 1] 2]) #@41 Paint error count on the puzzle screen. (defalias 'mpuz-paint-errors #[nil "\301 \210eb\210\302y\210\303\304!!\207" [mpuz-nb-errors mpuz-switch-to-window 2 mpuz-paint-number prin1-to-string] 3 (#$ . 8736)]) #@61 Paint statistics about previous games on the puzzle screen. (defalias 'mpuz-paint-statistics #[nil "eb\210\302y\210\303\304!!\210\303\305\306\307U\203\307\202\310 \\\245\"\311\312#\207" [mpuz-nb-completed-games mpuz-nb-cumulated-errors 6 mpuz-paint-number prin1-to-string format "%.2f" 0 0.0 3 2] 5 (#$ . 8950)]) #@45 Paint board situation on the puzzle screen. (defalias 'mpuz-paint-board #[nil "\300 \210\301\302\303\"\210eb\207" [mpuz-switch-to-window mapc mpuz-paint-digit [0 1 2 3 4 5 6 7 8 9]] 3 (#$ . 9276)]) #@53 Paint all occurrences of DIGIT on the puzzle board. (defalias 'mpuz-paint-digit #[(digit) " H\204\f\n H\203 \306\\\202 H\307\\\305\n H\203\"\310\202- H\203,\311\202-\312D\313\314\315 H\"+\207" [mpuz-found-digits digit mpuz-trivial-digits mpuz-digit-to-letter buffer-read-only face 48 65 mpuz-trivial mpuz-solved mpuz-unsolved nil mapc #[(square) "eb\210@Sy\210\303A!\210 c\210\304`S`\n#\210\305\306!\207" [square char face move-to-column set-text-properties delete-char 1] 4] char mpuz-board] 4 (#$ . 9480)]) #@37 Get the puzzle buffer if it exists. (defalias 'mpuz-get-buffer #[nil "\300\301!\207" [get-buffer "*Mult Puzzle*"] 2 (#$ . 10015)]) #@56 Find or create the Mult-Puzzle buffer, and display it. (defalias 'mpuz-switch-to-window #[nil "\302 \211\204\n\303 \304!\210\305\306 )\207" [buf buffer-read-only mpuz-get-buffer mpuz-create-buffer switch-to-buffer t mpuz-mode] 3 (#$ . 10152)]) #@21 Start a new puzzle. (defalias 'mpuz-start-new-game #[nil "\304\305!\210\306\307\310\n\311\"\210\310 \311\"\210\312 \210\313 \210\314 \210\315 \210\316 \207" [mpuz-nb-errors mpuz-in-progress mpuz-found-digits mpuz-trivial-digits message "Here we go..." 0 t fillarray nil mpuz-random-puzzle mpuz-switch-to-window mpuz-paint-board mpuz-paint-errors mpuz-ask-for-try] 3 (#$ . 10407)]) #@39 Multiplication puzzle with GNU Emacs. (defalias 'mpuz #[nil "\301 \210\203\n\302 \207\303 \207" [mpuz-in-progress mpuz-switch-to-window mpuz-offer-abort mpuz-start-new-game] 1 (#$ . 10796) nil]) #@44 Ask if user wants to abort current puzzle. (defalias 'mpuz-offer-abort #[nil "\304\305!\203\306 \307\310!\210\311\312\313 \311\"\210\205\314!)\207\315 \207" [buf mpuz-in-progress mpuz-nb-errors mpuz-board y-or-n-p "Abort game? " mpuz-get-buffer message "Mult Puzzle aborted." nil 0 fillarray kill-buffer mpuz-ask-for-try] 3 (#$ . 10999) nil]) #@34 Ask for user proposal in puzzle. (defalias 'mpuz-ask-for-try #[nil "\300\301!\207" [message "Your try?"] 2 (#$ . 11357)]) #@57 Dings, unless global variable `mpuz-silent' forbids it. (defalias 'mpuz-ding #[(error) "\302=\206\204\303\302!\207 \205\303\302!\207" [mpuz-silent error t ding] 2 (#$ . 11485)]) #@41 Propose a digit for a letter in puzzle. (defalias 'mpuz-try-letter #[nil "\203m\306\211\211\f\226 \307ZH\nH\204!\nH\203,\310\311 \"\210\312\313!\202k\nH\204>\310\314 \"\210\312\313!\202k\310\315 \"\210\316 \211\317=\203O\316  \320V\204[ \321W\203g\310\322 #\210\312\313!\202k\323 \"+\207\324\325!\203v\326 \207\310\327!\207" [mpuz-in-progress digit-char digit letter-char last-command-event mpuz-letter-to-digit nil 65 message "%c already solved." mpuz-ding t "%c does not appear." "%c = " read-char 61 57 48 "%c = %c" mpuz-try-proposal y-or-n-p "Start a new game? " mpuz-start-new-game "OK. I won't." mpuz-found-digits mpuz-trivial-digits mpuz-board] 5 (#$ . 11677) nil]) #@45 Propose LETTER-CHAR as code for DIGIT-CHAR. (defalias 'mpuz-try-proposal #[(letter-char digit-char) "\306Z\n\307Z\f H H\204 H\203#\310\311 \307\\\"\202i H\2041 H\2038\310\312\n\"\202i U\203X\310\313\n#\210\314\315!\210 \316I\210\317 \205i\320 \202i\310\321\n#\210\314\316!\210T\322 +\207" [letter-char letter digit-char digit mpuz-letter-to-digit correct-digit 65 48 message "%c has already been found." "%c has already been placed." "%c = %c correct!" mpuz-ding nil t mpuz-check-all-solved mpuz-close-game "%c = %c incorrect!" mpuz-paint-errors mpuz-found-digits mpuz-trivial-digits mpuz-nb-errors] 4 (#$ . 12384)]) #@44 Housecleaning when puzzle has been solved. (defalias 'mpuz-close-game #[nil "\305 \n\\ T\306 \210\307\310\n\211\311U\203\312\202\313\n\314U\203$\315\202a\n\311U\203.\316\202a\n\317U\2038\320\202a\n\321U\203B\322\202a\n\323U\203L\324\202a\n\325W\203V\326\202a\n\327W\203`\330\202a\331$\304\332\f\"\210\333\323!\210\334\f\335P!\203y\336 \202|\304\337!)\207" [mpuz-in-progress mpuz-nb-cumulated-errors mpuz-nb-errors mpuz-nb-completed-games message nil mpuz-paint-statistics format "Puzzle solved with %d error%s. That's %s" 1 "" "s" 0 "perfect!" "very good!" 2 "good." 3 "not bad." 4 "not too bad..." 10 "bad!" 15 "awful." "not serious." "%s" sit-for y-or-n-p " Start a new game? " mpuz-start-new-game "Good Bye!"] 6 (#$ . 13038)]) #@32 Find solution for autosolving. (defalias 'mpuz-solve #[(&optional row col) "\300\301\302\"\210\303\207" [mapc #[(digit) " H\206+\n H\206+ \203'\f\203 \fB H\235\202# H\236?\206+\n \306I\207" [mpuz-found-digits digit mpuz-trivial-digits row col mpuz-board t] 3] [0 1 2 3 4 5 6 7 8 9] t] 3 (#$ . 13799)]) #@42 Display solution for debugging purposes. (defalias 'mpuz-show-solution #[(row) "\301 \210\302\205 \303\304!_!\210\305 \210\306 \205\307 \207" [row mpuz-switch-to-window mpuz-solve 2 prefix-numeric-value mpuz-paint-board mpuz-check-all-solved mpuz-close-game] 4 (#$ . 14118) "P"]) (provide 'mpuz)