(defmacro move-boxes-9001 (command stacks)
(let (
(tmp (gensym))
(cnt (gensym))
(src (gensym))
(dst (gensym))
(source-stack (gensym)))
`(let ((,tmp (loop
for start = 0 then (1+ split)
for split = (position #\ ,command :start start)
when (and (null split) (not (= start (length ,command))))
collect (subseq ,command start)
while split
when (> split start) collect (subseq ,command start split))))
(let ((,cnt (parse-integer (second ,tmp)))
(,src (- (parse-integer (fourth ,tmp)) 1))
(,dst(- (parse-integer (sixth ,tmp)) 1)))
(let ((,source-stack (nth ,src ,stacks)))
(setf (nth ,dst ,stacks) (append (subseq ,source-stack 0 ,cnt) (nth ,dst ,stacks)))
(setf (nth ,src ,stacks) (subseq ,source-stack ,cnt)))))))