Skip to content

Instantly share code, notes, and snippets.

@spg
Created December 2, 2017 19:20
Show Gist options
  • Save spg/2e8ebb6de49c8c21bb62182757795aec to your computer and use it in GitHub Desktop.
Save spg/2e8ebb6de49c8c21bb62182757795aec to your computer and use it in GitHub Desktop.
import json
import random
from collections import namedtuple
Object = namedtuple(field_names=['determiner', 'object'], typename='Object')
objects = [
Object('A', 'Star Wars Mug'),
Object('A', 'Mickey Mouse Toaster'),
Object('Some', 'Socks'),
Object('A', 'Cup of tea'),
Object('A', 'Pack of Bacon'),
Object('A', 'Sweater'),
Object('A', 'Cat'),
Object('A', 'Waffle maker'),
Object('A', 'Robot vacuum cleaner'),
Object('A', 'Harry Potter Scarf'),
Object('A', 'Ring'),
Object('A', 'String'),
Object('A', 'Hamster'),
Object('A', 'Macbook'),
Object('A', 'Ghost'),
Object('A', 'Anaconda'),
Object('A', 'Dwarf'),
Object('A', 'Mathieu Marcotte BubbleHead'),
]
adjectives = [
'Crazy',
'Cool',
'Funny-looking',
'Sweet',
'Ugly',
'Disturbing',
'Awesome',
'Scary',
'Unfunny',
'Useless',
'Out of control',
'Huge',
'Long',
'Small',
'Tiny',
'Splendid',
'Expensive',
'Unique',
'Precious',
]
def generate_gift_idea():
obj = random.choice(objects)
adjective = random.choice(adjectives)
return f'{obj.determiner} {adjective.lower()} {obj.object}'
def handler(event, context):
gift_idea_count = random.randint(2, 6)
gift_ideas = [generate_gift_idea() for _ in range(gift_idea_count)]
return {
"statusCode": 200,
"body": json.dumps({
'gift_ideas': gift_ideas
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment