Here's an easy math riddle!

wonder

Expert
Licensed User
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:

sorex

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

GKCS

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

My guess is ENDLESS possibilities ...
 

wonder

Expert
Licensed User
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
Licensed User
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 ;)
 

udg

Expert
Licensed User
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
Licensed User
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
Licensed User
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
 

LucaMs

Expert
Licensed User
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

In addition, some combinations are disgusting :D
 
Top