How to order number (attribute) in a table?
stefdelec
Member, PRO Posts: 146
Hi,
I am creating a game. Let's say it is a dice game, with 5 dice. So I can get 1,2,3,4,5 or 6. I'd like to be able to know if there is 5 dice with the same number (2 2 2 2 2 or 3 3 3 3 3 3). Or if there is a sequence 1 2 3 4 5 or 2 3 4 5 6. My problem is dice can be 2 3 4 5 1, or 3 4 2 1 5....etc.
I was thinking to put in ascending order all the value in a table, and then check them.
What do you think?
Regards,
Stéphane.
Comments
1x2x3x4x5/6 = 20
6x5x4x3x2/1 = 720
You could perform a simple calculation on the 6 attributes in order.
If AxBxCxDxE/F = 20 . . .
Or . . .
If A<B and B<C and C<D . . .
Tks for the calculation. However: 1x1x4x5x6/6=20 too. And I have only 5 dices.
the "A<B and B<C and C<D" technic looks a bit too...boring to do! :-) That's why I asked. Also, if A<B and C<B. I don't know if C is < or > than A.
Do you think I could do something with a loop?
Perhaps use a quick bubble sort like this.
You can do the same thing with a loop, but for smaller sets of numbers, this way is quicker.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
The three dots at the end of what I wrote indicate that it continues as laid out, so if you see something that says "all the odd numbers should look like this 1 3 5 7 9 11 13 . . . . " you could point out that they have forgotten 15 (and every other larger odd number), but you might be missing the point/s !
Can you help me with a loop? I started something but I am getting confused...