Posted by free-zombie on Mon 27 Oct 22:37
report abuse | View followups from free-zombie | download | new post
- (defun with-unique-digits (to)
- (let ((ndigits (ceiling (log to 10))))
- (find-uniques to () ndigits 0)
- ))
- (defun find-uniques (max forbidden ndigits add)
- (cond
- ((> add max) ())
- ((= ndigits 0) (list add))
- (t (append
- (if (member 0 forbidden) ()
- (find-uniques max (and forbidden (cons 0 forbidden)) (1- ndigits) add))
- (loop for i from 1 to 9
- append (if (member i forbidden) ()
- (find-uniques max (cons i forbidden) (1- ndigits)
- (+ add (* i (expt 10 (1- ndigits))))))
- )
- ))
- ))
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.