Random number generator (lottery)

SUP people. I'm doing random number generator but it is like lottery. With one press on the button i generate 7 diffrent numbers. My problem is how to make them that there are diffrent number and there cant be any numbers that are the same. Thanks for responds! <3!

1 Like

Hello @urbanamon. Welcome to the MIT AI2 Community!
Perhaps the following code might help you:
image

2 Likes

The "join" block can be found in the text column, while the "random integer" block is in the Math one.

1 Like

@NishyanthKumar You need to handle the fact that your blocks do not guarantee 7 different/unique numbers....

1 Like

@TIMAI2, right, something I was maybe a little too oblivious to :weary:

1 Like

Also, using the join block as you do creates one long number, not 7 numbers.

2 Likes

This should be better:

1 Like

Closer, but still not correct.

Try something like this:

oops - see below

You may want to sort the numbers in the list after they have been generated.

2 Likes

This solution would leave you short of 7 numbers if you got any duplicates.

There are two solutions at

1 Like

Yes, left out a counter:

3 Likes

That is my designer... I hope u can understand my language. I'm from Slovenia but i think if u do this often u dont need translate... Text for label its just title...but just in case u need translate:
število=number
prvo=first
drugo= second,.....
generiraj števila=generate numbers

Try this: lottery_7.aia (11.9 KB)

grafik

2 Likes

where can i find call (puprple) block?

Or this:

1 Like

Get current millis using Clock component.
Somehow get last 7 digits.

I cant find call ListAddon1. bubbleSort list....i have only three purple blocks

grafik

1 Like

Hmm, for what purpose? How should that help?

To generate a random 7 digit unique number.
However, digits will not be unique, always.