random numbers without duplicates
BlitzPlus Forums/BlitzPlus Beginners Area/random numbers without duplicates
| ||
how can i generate random numbers without duplicate values? say i want o\p something like this o\p--- 6,2,1,5,10,8,7,3,4,9 the o\p is random numbers from 1 to 10 without any duplicate values i also want to know how can i "shuffle" elements(objects ) of a Collection(Type) type alien field val end type for i = 1 to 100 a.alien = new alien a\val = i nxt i want to shuffle the objects of this collection so that i get a "shuffled o\p" how can i do this ? |
| ||
You could use the "Insert" command to change the order of the Type. For instance: "Insert a Before First alien" With the After or Before command, you can 'scan' through the type. For instance like this: a.alien = First alien for g = 0 to rand(10) if a <> last alien then a = After a else exit next |