exodus
Jun 21st 2007, 6:35 pm
This is kind of hard to explain.
For example the list: 1 99 67 34 23
I would like a script that could take a string of space separated numbers that could be any amount and any numbers inputed and then pair them up with each other, but not itself.
Output would be like
1 99
1 67
1 34
1 23
99 1
99 67
99 34
99 23
67 1
and so forth.
The problem I am having is I can't come up with the formula to take a dynamic set of numbers to pair them up with each other. The above is 5 numbers, but users might enter 3 numbers even up to ten numbers.
Is it really easy and I am just over looking something?
I was thinking about using a for loop with a array shift and an array push to be able to do it, but i get stuck thinking about it. I know the number it would produce is the number of numbers times itself and I might should setup the for loop with that number.
Please, help me figure this out, thanks!
*No this is not a homework assignment.
For example the list: 1 99 67 34 23
I would like a script that could take a string of space separated numbers that could be any amount and any numbers inputed and then pair them up with each other, but not itself.
Output would be like
1 99
1 67
1 34
1 23
99 1
99 67
99 34
99 23
67 1
and so forth.
The problem I am having is I can't come up with the formula to take a dynamic set of numbers to pair them up with each other. The above is 5 numbers, but users might enter 3 numbers even up to ten numbers.
Is it really easy and I am just over looking something?
I was thinking about using a for loop with a array shift and an array push to be able to do it, but i get stuck thinking about it. I know the number it would produce is the number of numbers times itself and I might should setup the for loop with that number.
Please, help me figure this out, thanks!
*No this is not a homework assignment.