# Here's an easy math riddle!

#### wonder

##### Expert
You own a small cocktail bar with 8 different bottles:

- Vodka
- Gin
- Rum
- Whiskey
- Tequila
- Martini
- Mango Juice
- Cola

You need to come up with the menu for the grand opening tonight.
How many different cocktails would you be able to create with your shaker?

For this problem, each cocktail may only contain 2 drinks.
Also, remember that a drink mixed with itself is not a cocktail.

Last edited:

(8^8)-8 ? 56

#### sorex

##### Expert
or will you mix with 3 or more aswell? (then it's still too early to thing about that )

#### eurojam

##### Well-Known Member
7+6+5+4+3+2+1

now I am drunk .... after having 28 drinks...

28

#### GKCS

##### Member
is 10% Gin with 90% Martini the same Cocktail than 90% Gin with 10% Martini?

My guess is ENDLESS possibilities ...

#### LucaMs

##### Expert
I do not participate: I am a teetotaler

#### LucaMs

##### Expert
56 is not right, because it is:

8 * 7! / (7-6)! = 56

but it is "recursive":

7 * 6! / (6-5)!
...

#### LucaMs

##### Expert
I forgot to mention, you only pairs, 2 drinks per cocktail.
You have forgotten, I read now

#### wonder

##### Expert
CORRECT!! Well done!
The answer is [((n^2 + n) / 2) - n] which is 28.
Why? Because a Whiskey-Cola is the same as a Cola-Whiskey.

It was based on this kind of logic that I built my new collision detector.

Old code:

B4X:
``````Dim number_of_characters = 256 as Int 'Originally as Boolean (ahahah, thx Informatix)
Dim Collision(256, 256) as Boolean

For host = 0 to (number_of_characters - 1)
For guest = 0 to (number_of_characters - 1)
Collision(host, guest) = CheckCollision(host, guest)
Next
Next

'Number of Collision Checks: 65536``````

My new method:
B4X:
``````Dim number_of_characters = 256 as Int 'Originally as Boolean (ahahah, thx Informatix)
Dim Collision(256, 256) as Boolean

For host = 0 to (number_of_characters - 1)
For guest = host + 1 to (number_of_characters - 1)
Collision(host, guest) = CheckCollision(host, guest)
Collision(guest, host) = Collision(host, guest)
Next
Next

'Number of Collision Checks: 32640``````

For more on this subject, Google: Triangular Numbers

Last edited:

#### sorex

##### Expert
Why? Because a Whiskey-Cola is the same as a Cola-Whiskey.
actually it's not always the case, some drinks are forbidden to be shaken because the stuff isn't supposed to mix and are floating on top of each other.

so if you have whiskey-cola it will taste different than cola-whiskey because you get the other stuff in your mouth first

#### sorex

##### Expert
The answer is [((n^2 + n) / 2) - n] which is 28
why not (N^2-n)/2 ?

#### udg

##### Expert
The answer is [((n^2 + n) / 2) - n] which is 28.
Probably I'm wrong, but I reached the same correct result applying [n! / (n-k)!] /2 that derives from what in Italian is called "Disposizioni semplici", where "n" are the objects and "k" are the elements put together. Final division accounts for couples like Gin-Rum / Rum-Gin.

udg

#### JordiCP

##### Well-Known Member
Probably I'm wrong, but I reached the same correct result applying [n! / (n-k)!] /2 that derives from what in Italian is called "Disposizioni semplici", where "n" are the objects and "k" are the elements put together. Final division accounts for couples like Gin-Rum / Rum-Gin.

udg
I think the general formula is n!/[(n-k)!*k!]

Where the k! plays the same role as the "2" but with k elements (for k=3 --> k!=3.2=6 --> Gin-Rum-Vodka , Gin-Vodka-Rum, Rum-Gin-Vodka, Rum-Vodka-Gin, Vodka-Rum-Gin, Vodka-Gin-Rum )

#### derez

##### Expert
R1 over R2 : (in this case 8 over 2)
B4X:
``````Dim mul As Int = 1
For i = 1 To R2
mul = mul * ((R1+1-i)/i)
Next
result = mul``````