# Generate 3 different random numbers without duplic

Get help using Construct 2

### » Mon May 14, 2012 10:57 pm

This post has been super helpful in assisting me in understanding tokens and how to randomly pull from them. I am having one hang up with Yann's example. In the line
"System: set list to (left(list,0,1) = ",") ? right(list,len(list)-1) : list"
Construct is telling me that left can only have to parameters? What am I missing? been beating my head on this for a full day trying to understand. And Special thanks to Yann! always popping up in the forums I have searched with some intense tech responses.
B
6
S
2
G
2
Posts: 6
Reputation: 1,801

### » Tue May 15, 2012 1:07 am

@ASBanks
yeah probably made a mistake in the two last lines
[code]-> System: set list to (left(list,0,1) = ",") ? right(list,len(list)-1) : list
-> System: set list to (right(list,len(list-1),1) = ",") ? left(list,len(list)-1) : list[/code]

should be[code]-> System: set list to (left(list,1) = ",") ? right(list,len(list)-1) : list
-> System: set list to (right(list,1) = ",") ? left(list,len(list)-1) : list[/code]
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,336

### » Tue May 15, 2012 5:15 pm

I think the best and easiest way to do this without a lot extra steps like the token way is to use arrays. Plus its scalable for any amount of numbers/strings/etc.

Make an array and fill it with all your possible choices (in this case numbers) pick a random number from the size of the array and then get that number out of the array and store it however you want to store your 3 picked numbers. Then remove that number from the array.

Once its removed from the array it wont be able to be picked a 2nd time cause it no longer exists unless you added it more than once to the array
B
13
S
5
G
2
Posts: 306
Reputation: 3,262

### » Tue May 15, 2012 6:15 pm

Awesome! thanks Guys!
B
6
S
2
G
2
Posts: 6
Reputation: 1,801

Previous

Return to How do I....?

### Who is online

Users browsing this forum: 99Instances2Go, Eren, gomotion100, mindragon73, PatrikTT, Phoenixbowman, Solomon and 6 guests