Both left and right should yield good results for an arbitrary maze... I thought,.
Anyway, this works (I think!)
(defun labyrinth (lst / get_nth A CHK CHKN I J L LST OLST OP OPN X Y)
;; by Lee McDonnell
(setq oLst '((1 0) (0 -1) (-1 0) (0 1)))
(defun get_nth (u v op)
(setq u (+ (car op) u) v (+ (cadr op) v))
(nth u (nth v lst)))
;; Find Coordinates of Start Position
(setq l lst i 0 j 0)
(while
(progn
(setq x (caar l))
(cond ( (not x) (setq i nil j nil))
( (= 2 x) nil)
( (< 1 (length (car l)))
(setq l (cons (cdar l) (cdr l)) i (1+ i)))
( (setq l (cdr l) j (1+ j) i 0)))))
;; "Wall the Labyrinth"
(setq lst (mapcar
(function
(lambda (x)
(append '(0) x '(0)))) lst))
(repeat (length (car lst))
(setq a (cons 0 a)))
(setq lst (append (list a) lst (list a)) i (1+ i) j (1+ j))
;; Get the first Operator
(foreach x '((1 0) (0 -1) (-1 0) (0 1))
(if (not (zerop (nth (+ (car x) i)
(nth (+ (cadr x) j) lst))))
(setq opn (vl-position x oLst))))
(setq chkn (if (zerop opn) 3 (1- opn)))
(while
(progn
(setq op (nth opn oLst) chk (nth chkn oLst))
;; get Target square
(setq x (get_nth i j op)
;; Get Right hand check
y (get_nth i j chk))
(print (list (1- i) (1- j)))
(cond ( (and (= 1 x) (zerop y))
(mapcar 'set '(i j) (mapcar '+ (list i j) (nth opn oLst))))
( (and (or (= 0 x) (= 1 x)) (= 1 y))
(setq chkn (if (= 0 chkn) 3 (1- chkn))
opn (if (= 0 opn) 3 (1- opn)))
(mapcar 'set '(i j) (mapcar '+ (list i j) (nth opn oLst))))
( (and (= 0 x) (or (= -1 y) (= 0 y)))
(setq chkn (if (= 3 chkn) 0 (1+ chkn))
opn (if (= 3 opn) 0 (1+ opn))))
( (= -1 x) nil)))) ;; exit
(princ))