shiro #1384(2007/07/24 07:31 GMT) [ Scheme ] Rating0/0=0.00
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
(use srfi-1) (use srfi-42) (use file.util) (use gauche.sequence) (use gauche.array) (define (read-map file) (let1 rows (file->string-list file) (apply array (shape 0 (size-of rows) 0 (size-of (car rows))) (concatenate (map string->list rows))))) (define (map-width m) (array-length m 1)) (define (map-height m) (array-length m 0)) (define (search m x y) (define (try x y) (and (< -1 x (map-width m)) (< -1 y (map-height m)) (eqv? (array-ref m y x) #\+) (or (= y (- (map-height m) 1)) (search m x y)))) (array-set! m y x #\*) (or (try (- x 1) y) (try (+ x 1) y) (try x (+ y 1)) (try x (- y 1)))) (define (connected? m) (any?-ec (: x 0 (map-width m)) (and (eqv? (array-ref m 0 x) #\+) (search m x 0)))) (define (main args) (print (connected? (read-map (cadr args)))))
Rating0/0=0.00-0+
[ reply ]
shiro
#1384()
[
Scheme
]
Rating0/0=0.00
Rating0/0=0.00-0+
[ reply ]