; your code goes here
(defun all-indexes-1 (len numbers pattern)
(if (null numbers)
(list pattern)
(let (patterns)
(dolist (n numbers)
(setf patterns
(nconc patterns
(all-indexes-1 len
(remove n numbers)
(cons n pattern)))))
patterns)))
(defun all-indexes (len)
(all-indexes-1
len
(loop for n below len collect n)
nil))
(defun all-patterns (seq)
(let ((len (length seq))
(acc))
(dolist (indexes (all-indexes len))
(let ((new (make-sequence (type-of seq) len)))
(loop for i from 0 by 1
for j in indexes
do
(setf (aref new i)
(aref seq j)))
(push new acc)))
acc))
(mapc #'print (all-patterns "abcd"))
OyB5b3VyIGNvZGUgZ29lcyBoZXJlCgooZGVmdW4gYWxsLWluZGV4ZXMtMSAobGVuIG51bWJlcnMgcGF0dGVybikKICAoaWYgKG51bGwgbnVtYmVycykKICAgICAgKGxpc3QgcGF0dGVybikKICAgICAgKGxldCAocGF0dGVybnMpCgkoZG9saXN0IChuIG51bWJlcnMpCgkgIChzZXRmIHBhdHRlcm5zCgkJKG5jb25jIHBhdHRlcm5zCgkJICAgICAgIChhbGwtaW5kZXhlcy0xIGxlbgoJCQkJICAgICAgKHJlbW92ZSBuIG51bWJlcnMpCgkJCQkgICAgICAoY29ucyBuIHBhdHRlcm4pKSkpKQoJcGF0dGVybnMpKSkKCihkZWZ1biBhbGwtaW5kZXhlcyAobGVuKQogIChhbGwtaW5kZXhlcy0xCiAgIGxlbgogICAobG9vcCBmb3IgbiBiZWxvdyBsZW4gY29sbGVjdCBuKQogICBuaWwpKQoKKGRlZnVuIGFsbC1wYXR0ZXJucyAoc2VxKQogIChsZXQgKChsZW4gKGxlbmd0aCBzZXEpKQoJKGFjYykpCiAgICAoZG9saXN0IChpbmRleGVzIChhbGwtaW5kZXhlcyBsZW4pKQogICAgICAobGV0ICgobmV3IChtYWtlLXNlcXVlbmNlICh0eXBlLW9mIHNlcSkgbGVuKSkpCgkobG9vcCBmb3IgaSBmcm9tIDAgYnkgMQoJICAgICAgZm9yIGogaW4gaW5kZXhlcwoJICAgICAgZG8KCQkgKHNldGYgKGFyZWYgbmV3IGkpCgkJICAgICAgIChhcmVmIHNlcSBqKSkpCgkocHVzaCBuZXcgYWNjKSkpCiAgICBhY2MpKQoKKG1hcGMgIydwcmludCAoYWxsLXBhdHRlcm5zICJhYmNkIikpCg==