logic's problem

p_yves's icon

Hi all,

I have two series of numbers (for example 0-->1000 and 0-->2000). I am trying to made a patch who can, for each bang, send a pair with one random number from each series. And each pair must not already have been used before.
I have try with a matrix (1 dimension for 1 serie) but after few minutes it's began to be very slow. Does somebody have a idea?

Thanks,

p_yves

Luke Hall's icon

Have a look at [urn], it is similar to the [random] object except that it remembers each number it generates and won't repeat it.

lh

Max Patch
Copy patch and select New From Clipboard in Max.

p_yves's icon

yes i already try this way, but urn just can play one time each number.

if my two series are 123456789 and abcdefghi for example, i'm gonna have many pairs with each number or each letter.

1b
1e
1h

just the pairs must be unique!

jvkr's icon

You could give each pair an index number and urn that. In your example there's 81 possibilities. 81/9 (not /9.) gives the index of the one and 81%9 the index of the other series.

_
johan

jko's icon

Or even use a coll filled with all possible combinations

Max Patch
Copy patch and select New From Clipboard in Max.

jko's icon

Sorry, too much cleaning up. this works hopefully :-)

Max Patch
Copy patch and select New From Clipboard in Max.

Luke Hall's icon

You need to insert a [+ 1] after the [counter] or set the minimum because at the moment the first count is zero so the argument for [urn] is 15 when it should be 16. Apart from that: nice patch!

lh

p_yves's icon

My aim is to recover progressively and randomly a picture, pixel by pixels.

So my two dimensions are actually closed to 2000 and 3000.

I need each pixel must be fill only on time.

Here is my first solution as a attached file.
In this patch i scan all the pixels of the matrix. If one pixel is empty (Alpha = 0), i fill it. If it's full, the patch try the next one.
But this process began really slow after a while. Because the scan used the random objet i guess.

I am a beginner, maybe my patch is to complicate.

Thanks JKO for your patch. I have tryed to used two list 0 to 2000 and 0 to 3000 but it seems to be to much for the "combine" objet because max msp crash in this case.

Is there a big mistake in my patch?