Page 1 of 1

### CLISP

Posted: Sat Nov 05, 2016 10:52 pm
Hey
I am beginner and just started to learn Clisp. Could someone please help me to create array of random integer number and find pair of numbers(from array) whose sum is equal to target number and also print their indices. Suppose if we create array of 10 number and target number is 8 then pair should be like (2 3 3), (4 4), (1 2 5), (8) with their indices
Thank you

### Re: CLISP

Posted: Sun Nov 06, 2016 1:14 pm
(2 3 3) isn't a pair. You mean any list of numbers?

### Re: CLISP

Posted: Tue Nov 08, 2016 1:57 pm
It is like if you generate 10 random number(5 8 7 2 3 5 2 6 8 1) then it should return all the subset whose sum is target number. If target number is 8 then it should return (8),(5 3),(7 1),(3 2 3),(1 5 2),(1 2 2 3).
.

### Re: CLISP

Posted: Tue Nov 08, 2016 4:35 pm
The fact that you haven't even attemted this makes it sound like a homework assignment.

Building an array of random numbers will involve the symbols MAKE-ARRAY DOTIMES RANDOM AREF, and SETF.

Finding the sub-lists that sum to a total is a naturally recursive problem, your first step would be to sort the array.