cooperの日記: BIP2004 - 1 2
日記 by
cooper
#!/usr/bin/env gosh
(use srfi-1)
(use gauche.regexp)
(define (usage)
(format (current-error-port) "Usage: ~a FILENAME" *program-name*)
(newline)
(exit 1))
(define nblist '())
(define (get-entry key)
(and nblist
(find (cut memq key <>) nblist)))
(define (add-entry! key value)
(let ((entry (get-entry key)))
(if entry
(set! (second entry) (cons value (second entry)))
(set! nblist (cons (cons key (cons (list value) '())) nblist)))))
(define (main args)
(if (null? (cdr args))
(usage)
(with-input-from-file (second args)
(lambda ()
(port-for-each
(lambda (line)
(rxmatch-let (rxmatch #/^(\d+) -> (\d+)$/ line)
(#f v w)
(add-entry! (string->number v) (string->number w))))
read-line)
(display nblist)
(newline))))
0)
;; 安直な隣接リストを構築して表示するだけのコード
;; problem.g を読んで /dev/null に吐くと 9 秒
;; さて、ここから統計的に有意な NM を取り出すには...
(use srfi-1)
(use gauche.regexp)
(define (usage)
(format (current-error-port) "Usage: ~a FILENAME" *program-name*)
(newline)
(exit 1))
(define nblist '())
(define (get-entry key)
(and nblist
(find (cut memq key <>) nblist)))
(define (add-entry! key value)
(let ((entry (get-entry key)))
(if entry
(set! (second entry) (cons value (second entry)))
(set! nblist (cons (cons key (cons (list value) '())) nblist)))))
(define (main args)
(if (null? (cdr args))
(usage)
(with-input-from-file (second args)
(lambda ()
(port-for-each
(lambda (line)
(rxmatch-let (rxmatch #/^(\d+) -> (\d+)$/ line)
(#f v w)
(add-entry! (string->number v) (string->number w))))
read-line)
(display nblist)
(newline))))
0)
;; 安直な隣接リストを構築して表示するだけのコード
;; problem.g を読んで /dev/null に吐くと 9 秒
;; さて、ここから統計的に有意な NM を取り出すには...
あはは (スコア:1)
3でおんなじようなことしてます。Ecol_K12_W3110_.wgsを読んで結果を全部吐くまで約28分(PowerBook G4 1GHz)。せめて15分くらいにならないかなー。
# コードは長くなるので貼りません。
えへへ (スコア:1)
-- cooper