Posted Monday at 07:05 AM4 days Dear all,I would like to make a function for the following purpose:I have a list of 4 lists. I would like to start from any of the numbers in the first list and choose the corresponding next or after next (could be random) higher numbers in the subsequent lists.Here an example:((2 8 9 14 20 21 26) (1 2 3 7 13 14 19 25 26) (0 6 7 12 18 19 24) (0 5 11 12 17 23 24))or((2 8 9 14 20 21 26) (1 2 3 7 13 14 19 25 26) (0 6 7 12 18 19 24) (0 5 11 12 17 23 24))or((2 8 9 14 20 21 26) (1 2 3 7 13 14 19 25 26) (0 6 7 12 18 19 24) (0 5 11 12 17 23 24))Has anyone an idea how to implement this?Thanks for help.Achim
Tuesday at 06:12 PM3 days Hi, Out of curiosity I asked the AI-promt Claude (https://claude.ai) and the code it spits out seem to work. Maybe it is useful as a starting point..? best(defun select-path (lists &optional start-num) (let ((current (if start-num start-num (nth (random (length (first lists))) (first lists)))) (result nil)) (push current result) (dolist (lst (rest lists)) (let* ((higher (remove-if (lambda (x) (<= x current)) lst)) (next (when higher (if (and (> (length higher) 1) (zerop (random 2))) (second higher) ; next-next higher (first higher))))) ; next higher (when next (setf current next) (push current result)))) (reverse result))) (select-path '((2 8 9 14 20 21 26) (1 2 3 7 13 14 19 25 26) (0 6 7 12 18 19 24) (0 5 11 12 17 23 24)) 8)
Wednesday at 06:07 PM2 days Author Say thanks to Claude from me 😀. I will have a look at that. Achim
Create an account or sign in to comment