Skip to content

Instantly share code, notes, and snippets.

@ellisvalentiner
Created January 5, 2024 01:23
Show Gist options
  • Save ellisvalentiner/d7d0740ff8f2de6671fff141ff66c831 to your computer and use it in GitHub Desktop.
Save ellisvalentiner/d7d0740ff8f2de6671fff141ff66c831 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
# ~*~ encoding: utf-8 ~*~
"""
make random drink for ben
"""
import random
from collections import Counter
MAX_PARTS = 10
data = {
"spirits": {
"vodka": [
"Absolut Mandarin",
"Absolut Vanilla",
"Absolut Plain",
"Titos",
"Grey Goose",
"Belvedere Pink Grapefruit",
],
"rum": ["Bacardi Superior", "Captain Morgan", "Malibu"],
"gin": ["Beefeter", "Tanqueray", "Bombay Sapphire"],
"whiskey": ["Jack Daniels", "Crown Royal"],
"scotch": ["Johnnie Walker Black Label", "Dewars"],
"tequila": ["Curevo Gold"],
},
"mixers": [
"Coke",
"Diet Coke",
"Sprite",
"Ginger Ale",
"Tonic",
"Soda Water",
],
"syrups": [
"Grenadine",
"Lime Cordial",
"Sweet and Sour",
],
"juices": [
"Cranberry Juice",
"Orange Juice",
"Pineapple Juice",
],
"garnishes": ["Lime", "Lemon"],
}
ingredients = []
for kind in data["spirits"].keys():
ingredients.extend(data["spirits"][str(kind)])
ingredients += data["mixers"] + data["garnishes"]
def make_drink():
"""
Assume 10 parts total.
Ice, yes or no. if yes, 1-5 parts.
Spirits 1-3 types, weighted toward 1, and only 1 per type of spirit.
Minimum 4 total parts spirit maximum 8.
0-3 mixers, minimum 4 parts maximum 8.
No more than 1 part of the syrups or 4 parts of the juices.
"""
# Determine how many parts are in the drink
MAX_PARTS = 10
parts_spirits = [4, 8]
parts_mixers = [4, 8]
parts_syrups = [0, 1]
parts_juices = [0, 4]
drink = []
# Determine whether to include ice
if random.choices([True, False], weights=[0.75, 0.25], k=1)[0]:
drink.extend(["Ice"])
# Determine how many spirit types
num_spirit_types = random.choices([1, 2, 3], weights=[0.75, 0.2, 0.05], k=1)[0]
# Determine which spirit types (only 1 per type)
for i in range(num_spirit_types):
# Only 1 per type
spirit_type = random.choice(list(data["spirits"].keys()))
# Determine how many parts of the spirit
for j in range(random.randint(1, 3)):
drink.append(random.choice(data["spirits"][spirit_type]))
# Determine how many parts of the mixers
for i in range(random.randint(parts_mixers[0], min(parts_mixers[1], MAX_PARTS - len(drink)))):
drink.append(random.choice(data["mixers"]))
# Determine how many parts of the syrups and juices
if random.choices([True, False], weights=[0.75, 0.25], k=1)[0]:
drink.append(random.choice(data["syrups"]))
for i in range(random.randint(parts_juices[0], min(parts_juices[1], MAX_PARTS - len(drink)))):
drink.append(random.choice(data["juices"]))
for ingredient, parts in Counter(drink).items():
print(f"{parts} part(s) of {ingredient}")
if __name__ == "__main__":
make_drink()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment