プログラミングのお題スレ Part8at TECH
プログラミングのお題スレ Part8 - 暇つぶし2ch749:デフォルトの名無しさん
16/09/07 01:44:45.83 Bbadz6db.net
>>726 Emacs Lisp

(require 'cl-lib)

(defun f (s)
(let* ((e (reduce (lambda (a b) (concat a (substring b 1)))
(mapcar (lambda (x) (let ((a (car x)) (b (cdr x)))
(macrolet ((c (d) `(loop for i from a ,d b concat (string i)))) (if (< a b) (c to) (c downto)))))
(loop for i from 0 below (1- (length s)) collect (cons (aref s i) (aref s (1+ i)))))))
(f (position ?: e)) (g (substring e 0 (1+ f))) (h (apply #'string (reverse (string-to-list (substring e f)))))
(w 0) (y '(((0 . 0) 0 nil))))
(while y
(let ((i (caaar y)) (j (cdaar y)))
(if (and (= (aref g i) ?:) (= (aref h j) ?:))
(setq w (cadar y) y nil)
(setq y (append y (mapcar (lambda (x) (list x (1+ (cadar y)) (cons (cons i j) (caddar y))))
(remove-if (lambda (x) (or (< (car x) 0) (< (cdr x) 0) (find x (caddar y) :test 'equal) (/= (aref g (car x)) (aref h (cdr x)))))
(list (cons (1+ i) (1+ j)) (cons (1+ i) (1- j)) (cons (1- i) (1+ j)) (cons (1- i) (1- j)))))))))
(pop y))
w))

(f "073:0") 18
(f "07362:450") 36
(f "06464:36470") 42
(f "0827171:28480") 66
(f "0737491:28180") 146
(f "05374734372747484:184618186912120") 400
(f "021:120") 12
(f "091:280") 62


次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch