randome no duplicates.

Jan 5, 2014 at 8:05am

randome no duplicates.

hi there everyone. i need to create a random object that puts out 10 integers between 1 and 26 without repeating any.

basically right now i have a bang into an {uzi 10} then into a {random 25} then into a {+ 1} then into {zl.group 10} then to a {message}

this eliminates 0 and puts out numbers between 1 and 26

HOWEVER!

there are repeats in the numbers which makes this useless for what i need it for.
can anyone help me get a string of 10 RANDOM numbers without any repeats?

many thanks in advance

MiRAGE

#277455
Jan 5, 2014 at 8:14am

If you look at the help file for [random], there is a list of “See Also” objects. I find this list to be incredibly useful when I’m looking for a particular function, but can’t think of the name of an object. Check out the object [urn], it does what you want.

#277457
Jan 5, 2014 at 9:34am

im not sure urn will do what i want.

—————-DESCRIPTION——————————
urn

Generate random numbers without duplicates

outputs random numbers and keeps track of each number that has been generated
When all numbers up to the maximum (set via an argument or the right inlet)
have been output, a bang is sent out the right outlet.

———————————————————

it seems like it sort of counts up to the maximum by randomly outputting values ore something. i have tried various combinations of this and i just cant see how it will work.
can someone explain how i would go about this with “urn” ? or if not how else i can reach my goal?

many thanks

#277469
Jan 5, 2014 at 10:07am

Send clear to urn after you generate your 10 unique integers.

<code>

– Pasted Max Patch, click to expand. –

</code>

#277470
Jan 5, 2014 at 10:12am

you would just replace ‘random 25′ with ‘urn 25′ and you could use the uzi finished bang to send a clear message to urn so you don’t run out of numbers – once urn has output all the numbers in the range you select it stops outputting until you send ‘clear’. Maybe this is what is confusing to you?

#277471

You must be logged in to reply to this topic.