Edited at

# オフラインリアルタイムどう書く第5回の参考問題をArcで解く

More than 5 years have passed since last update.

http://qiita.com/items/0ddde0164a745cd09c34

realtime_doukaku5.arc

```(= opposite '(2 3 0 1))
(= pattern '((2 3 0 1) (1 0 3 2) (3 2 1 0)))
(= adjacent (list [if (< -1 (- _ 3)) (- _ 3)]   ; up
[if (< (mod _ 3) 2) (++ _)]   ; right
[if (< (+ _ 3) 9) (+ _ 3)]    ; down
[if (< 0 (mod _ 3)) (-- _)])) ; left

(def run (lis idx side)
(let next ((pattern (lis idx)) side)
(cons idx
(run lis it (opposite next))))))

(def to-alphabet (l) (upcase (string (map [coerce (+ _ 97) 'char] l))))
(def to-numlis (s) (read (+ "(" (string (intersperse #\  (coerce s 'cons))) ")")))
(def solve (s) (to-alphabet (run (to-numlis s) 1 0)))
```

realtime_doukaku_5_result.arc

```(solve "101221102") ;-> "BEDGHIFEH"
(solve "000000000") ;-> "BEH"
(solve "111111111") ;-> "BCF"
(solve "000211112") ;-> "BEFIHEDGH"
(solve "000111222") ;-> "BEFIH"
(solve "012012012") ;-> "BC"
(solve "201120111") ;-> "BEDABCFI"
(solve "111000112") ;-> "BCFIHEBA"
(solve "001211001") ;-> "BEFI"
(solve "111222012") ;-> "BCFEHIF"