reconstruct permutat
public text v1 · immutable;; http://acm.mipt.ru/judge/problems.pl?problem=061
;; rmathews AT gmail DOT com
(defun reconstruct (n list)
(let ((result (loop for i from 1 to n
collect -1)))
(dotimes (i n)
(let ((pos (position 0 list)))
(when (null pos)
(return-from reconstruct "-1"))
(dotimes (i (1+ pos))
(setf (nth i list) (1- (nth i list))))
(setf (nth pos result) (- n i))))
result))