2012-01-01から1年間の記事一覧

Zenbook の右クリック問題

ubuntu 12.04 では Zenbook の右クリックが効かない不具合があったけれど 12.10 を入れたら解消されていた. すばらしい.

reftex で参照する bib ファイルを更新する

概要 reftex で参考文献を参照するときに, bib ファイルを外部から更新すると,emacs 内では bib ファイルが更新されず, 新しく追加した文献を C-c [ で見つけることができない.これをなんとかしたい. 解決策 reftex が参考文献を参照するときは, 裏で bib フ…

svg ファイルを eps に変換するシェルスクリプト

コード 説明 inkscape を使って svg ファイルを eps ファイルに変換. タイムスタンプを調べて, svg の更新日時が新しかった場合のみ変換. ワイルドカードで一括変換可能. ファイル名は元ファイルと同じ. 拡張子だけ eps に変更. 使い方 上記のコードを svg2e…

dvipdfmx の日本語フォントの設定方法

概要 ubuntu 12.04 を入れたので, dvipdfmx の設定. そのときのメモ Takao フォントを使う. 設定 フォントの登録 まず, Takao フォントを TeX のフォントディレクトリに入れる. TeX の読み込むフォントは /usr/share/texmf/fonts/ 以下におかれるので, そこ…

xdiv の日本語フォントの設定方法

概要 ubuntu 12.04 を入れたので, xdviの日本語フォントを設定. そのときのメモ. インストール # apt-get install xdvik-jaフォントは ubuntu 12.04 に標準で入っている Takao フォントを使うので, インストール不要. 設定 フォントマップファイルは /etc/te…

ubuntu 12.04 でインストールした TeX 関係のパッケージ

本体 texlive jsarticle okumura-clsfiles wrapfig.sty がないと言われたので texlive-extra emacs関連 yatex dvi, pdf関係 xdvik-ja, dvipdfmx

inkscape でスペルチェック

方法 version 0.47 から組み込まれている. 「テキスト」->「スペルチェック」で実行可能 (Ctrl+Alt+K でもOK) 参考サイト http://wiki.inkscape.org/wiki/index.php/Release_notes/0.47#Spell_checker

TeX 数式ラベル入力補助用 elisp -- texlabel.el v1.0.0

texlabel.el とは TeXの数式ラベル入力補助用の elisp です。 TeXの数式ラベルをいちいち打つのは面倒ですよね。 ラベル名を考えるのすら面倒です。 そんな悩みを解決してくれるようなelispを作りました。 概要 コマンド1つで適切な位置に番号順の数式ラベル…

Problem 22

(require 'calc-ext) (defvar calc-command-flags nil) (with-temp-buffer (insert-file-contents-literally (car argv)) (let (name-lst (i 1) (sum 0)) (while (re-search-forward "\"\\([A-Z]+?\\)\"" nil t) (setq name-lst (cons (match-string-no-prop…

Problem 21

(require 'cl) (require 'calc-ext) (defvar calc-command-flags nil) (defun hash-to-alist (hash) (let (alist) (maphash #'(lambda (key val) (push (cons key val) alist)) hash) alist )) (defun find-factor (num) (catch 'found (let ((i 2)) (while …

Problem 20

(require 'calc-ext) (defvar calc-command-flags nil) (defun factorial (n) (let ((rst 1)) (while (math-lessp 0 n) (setq rst (math-mul rst n)) (setq n (math-sub n 1)) ) rst )) (defun digit-sum (n) (let* ((str (math-format-value n)) (len (leng…

Problem 19

(defvar month-day-alist '((1 . 31) (2 . 28) (3 . 31) (4 . 30) (5 . 31) (6 . 30) (7 . 31) (8 . 31) (9 . 30) (10 . 31) (11 . 30) (12 . 31))) (defun assq-val (key alist) (cdr (assq key alist))) (defun next-month (year month day) (let ((days (…

Probrem 18

(defun read-txt-numbers (file-name) (let (num-lst) (with-temp-buffer (insert-file-contents-literally file-name) (goto-char (point-min)) (while (re-search-forward "[0-9]+" nil t) (setq num-lst (cons (string-to-number (match-string 0)) num-l…

Problem 17

(defvar num-str-alist '((1 . "one") (2 . "two") (3 . "three") (4 . "four") (5 . "five") (6 . "six") (7 . "seven") (8 . "eight") (9 . "nine") (10 . "ten") (11 . "eleven") (12 . "twelve") (13 . "thirteen") (14 . "fourteen") (15 . "fifteen") …

Problem 15

(require 'calc-ext) (defvar calc-command-flags nil) (defun factorial (n) (let ((rst 1)) (while (math-lessp 0 n) (setq rst (math-mul rst n)) (setq n (math-sub n 1)) ) rst )) (let ((size (string-to-number (car argv)))) (princ (math-format-va…

Problem 14

(require 'calc-ext) (defvar calc-command-flags nil) (let ((limit (math-add (math-read-number (car argv)) 1)) (hash (make-hash-table)) (i 1) (max-i 1)) (while (math-lessp i limit) (let ((n i) (len 0) found) (while (not (math-equal n 1)) (if…

Problem 16

(require 'calc-ext) (defvar calc-command-flags nil) (defun convert-decimal-to-binary (d) (let (b (i 0)) (while (> d 0) (setq b (cons (if (eq (% d 2) 0) 0 1) b)) (setq d (/ d 2)) (setq i (1+ i)) ) b)) (defun digits-sum (str) (let ((sum 0)) …

Problem 13

(require 'calc-ext) (defvar calc-command-flags nil) (with-temp-buffer (insert-file-contents-literally (car argv)) (let ((sum 0)) (while (re-search-forward "[0-9]\\{50\\}" nil t) (setq sum (math-add sum (math-read-number (match-string-no-pr…

Problem 11

(require 'cl) (defun make-ad-lst (pivot len grid-size) (let* ((idx (1- len)) (right (loop for i from 0 to idx collect i)) (down (loop for i from 0 to idx collect (* grid-size i))) (right-down (loop for i from 0 to idx collect (+ (* grid-si…

Problem 10

(require 'calc-ext) (defvar calc-command-flags nil) (defun find-factor (num) (catch 'found (let ((i 2)) (while (math-lessp (math-sub i 1) (math-floor (math-sqrt num))) (if (math-equal (math-mod num i) 0) (throw 'found i) (setq i (math-add …

Problem 12

(require 'cl) (require 'calc-ext) (defvar calc-command-flags nil) (defun find-factor (num) (catch 'found (let ((i 2)) (while (math-lessp (math-sub i 1) (math-floor (math-sqrt num))) (if (math-equal (math-mod num i) 0) (throw 'found i) (set…

Problem 9

(let* ((n (string-to-number (car argv))) (a 1) b c ans) (setq ans (catch 'found (while (<= a (/ n 3)) (setq b (1+ a)) (while (<= b (/ (- n a) 2)) (setq c (- n a b)) (if (= (+ (* a a) (* b b)) (* c c)) (throw 'found (list a b c)) ) (setq b …

Problem 8

(require 'cl) (let* ((str "\ 73167176531330624919225119674426574742355349194934\ 96983520312774506326239578318016984801869478851843\ 85861560789112949495459501737958331952853208805511\ 12540698747158523863050715693290963295227443043557\ 66…

Problem 7

(require 'calc-ext) (defvar calc-command-flags nil) (defun find-factor (num) (catch 'found (let ((i 2)) (while (math-lessp (math-sub i 1) (math-floor (math-sqrt num))) (if (math-equal (math-mod num i) 0) (throw 'found i) (setq i (math-add …

Problem 6

(require 'cl) (defun make-1-to-n-list (n) (loop for i from 1 to n collect i)) (defun 2pow (x) (* x x)) (let* ((num-lst (make-1-to-n-list (string-to-number(car argv)))) (x (apply #'+ (mapcar #'2pow num-lst))) (y (2pow (apply #'+ num-lst))))…

Problem 5

(require 'cl) (defun make-1-to-n-list (n) (loop for i from 1 to n collect i)) (princ (apply #'lcm (make-1-to-n-list (string-to-number (car argv))))) (princ "\n") 追記 make-1-to-n-list を定義しなくても, emacs の標準関数により汎用的な関数 nu…

Problem 4

(defun mirror-num (num) (let* ((str (int-to-string num)) (len (length str)) elt) (dotimes (i (floor (/ len 2))) (setq elt (aref str i)) (aset str i (aref str (1- (- len i)))) (aset str (1- (- len i)) elt)) (string-to-int str) )) (let ((i 1…

Problem 3

(require 'calc-ext) (defvar calc-command-flags nil) (defun find-factor (num) (catch 'found (let ((i 2)) (while (math-lessp (math-sub i 1) (math-floor (math-sqrt num))) (if (math-equal (math-mod num i) 0) (throw 'found i) (setq i (math-add …

Problem 2

(let ((a 1) (b 1) (c 0) (rst 0)) (while (< a 4000000) (if (eq (% a 2) 0) (setq rst (+ rst a)) ) (setq c a) (setq a (+ a b)) (setq b c) ) (princ rst) (princ "\n"))

Problem 1

(let ((rst 0)) (dotimes (i 1000) (if (or (eq (% i 3) 0) (eq (% i 5) 0) ) (setq rst (+ rst i)) )) (princ rst) (princ "\n") ) elisp でやっていくぜよ