Answer: LISP conditional loopssteemCreated with Sketch.

in common-lisp •  7 years ago 

Question: https://stackoverflow.com/questions/50204220/

Snapshot:

The actual solution steps will be similar to the following, because the problem does not provide the relevant functions, the list as an example, can not solve the problem best:

(let ((population-amount 10)
      (all-guess '()))
  (loop
     (if (= (length
             (setf all-guess
                   (remove-duplicates all-guess)))
            population-amount)
         ;; exit when all-guess's items are unique
         (return all-guess)
         ;; make new guess, for example, a random number ∈[0,9]
         (push (random 10)
               all-guess))))

Return:

(7 9 5 2 4 8 1 6 0 3)

Or

(5 8 3 1 0 9 7 4 2 6)

Or etc.

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!