Skip to content

Instantly share code, notes, and snippets.

@luizomf
Last active March 24, 2020 12:26
Show Gist options
  • Select an option

  • Save luizomf/201be460bca330a9cdb51fde891c77a2 to your computer and use it in GitHub Desktop.

Select an option

Save luizomf/201be460bca330a9cdb51fde891c77a2 to your computer and use it in GitHub Desktop.
import itertools
from pprint import pprint
hotdogs = ['SimpleHotdog', 'SpecialHotdog']
ingredients = ['Sausage', 'Bacon',
'Egg', 'Cheese', 'MashedPotatoes',
'PotatoSticks']
classnames = []
for ingredient in ingredients:
for i, j in itertools.combinations(range(len(ingredients) + 1), 2):
if ingredient in ingredients[i:j]:
continue
value = set([ingredient, *ingredients[i:j]])
if value in classnames:
continue
classnames.append(value)
all_classnames = []
for hotdog in hotdogs:
for classname in sorted(classnames, key=lambda item: ''.join(item)):
all_classnames.append(f'{hotdog}Bread{"".join(classname)}')
pprint(all_classnames)
pprint(len(all_classnames))
"""
['SimpleHotdogBreadBaconCheeseEggPotatoSticks',
'SimpleHotdogBreadBaconEggPotatoSticks',
'SimpleHotdogBreadCheeseBacon',
'SimpleHotdogBreadCheeseEggBacon',
'SimpleHotdogBreadCheeseEggPotatoSticks',
'SimpleHotdogBreadCheeseMashedPotatoesEggBacon',
'SimpleHotdogBreadCheesePotatoSticksBaconMashedPotatoesEgg',
'SimpleHotdogBreadEggBacon',
'SimpleHotdogBreadEggCheese',
'SimpleHotdogBreadEggMashedPotatoesBacon',
'SimpleHotdogBreadEggPotatoSticks',
'SimpleHotdogBreadEggSausageMashedPotatoesBacon',
'SimpleHotdogBreadMashedPotatoesBacon',
'SimpleHotdogBreadMashedPotatoesCheese',
'SimpleHotdogBreadMashedPotatoesCheeseBacon',
'SimpleHotdogBreadMashedPotatoesEgg',
'SimpleHotdogBreadMashedPotatoesEggCheese',
'SimpleHotdogBreadMashedPotatoesEggPotatoSticks',
'SimpleHotdogBreadMashedPotatoesPotatoSticks',
'SimpleHotdogBreadMashedPotatoesPotatoSticksCheeseBacon',
'SimpleHotdogBreadMashedPotatoesPotatoSticksEggCheese',
'SimpleHotdogBreadPotatoSticksBacon',
'SimpleHotdogBreadPotatoSticksCheese',
'SimpleHotdogBreadPotatoSticksMashedPotatoesBacon',
'SimpleHotdogBreadPotatoSticksMashedPotatoesCheese',
'SimpleHotdogBreadSausageBacon',
'SimpleHotdogBreadSausageBaconCheese',
'SimpleHotdogBreadSausageBaconEggPotatoSticks',
'SimpleHotdogBreadSausageBaconPotatoSticks',
'SimpleHotdogBreadSausageCheese',
'SimpleHotdogBreadSausageCheeseBaconMashedPotatoesEgg',
'SimpleHotdogBreadSausageCheeseEggBacon',
'SimpleHotdogBreadSausageCheesePotatoSticksBaconEgg',
'SimpleHotdogBreadSausageCheesePotatoSticksBaconMashedPotatoesEgg',
'SimpleHotdogBreadSausageEgg',
'SimpleHotdogBreadSausageEggBacon',
'SimpleHotdogBreadSausageEggCheese',
'SimpleHotdogBreadSausageMashedPotatoes',
'SimpleHotdogBreadSausageMashedPotatoesBacon',
'SimpleHotdogBreadSausageMashedPotatoesCheese',
'SimpleHotdogBreadSausageMashedPotatoesEggCheese',
'SimpleHotdogBreadSausageMashedPotatoesPotatoSticks',
'SimpleHotdogBreadSausagePotatoSticks',
'SimpleHotdogBreadSausagePotatoSticksCheeseMashedPotatoesEgg',
'SimpleHotdogBreadSausagePotatoSticksMashedPotatoesCheese',
'SpecialHotdogBreadBaconCheeseEggPotatoSticks',
'SpecialHotdogBreadBaconEggPotatoSticks',
'SpecialHotdogBreadCheeseBacon',
'SpecialHotdogBreadCheeseEggBacon',
'SpecialHotdogBreadCheeseEggPotatoSticks',
'SpecialHotdogBreadCheeseMashedPotatoesEggBacon',
'SpecialHotdogBreadCheesePotatoSticksBaconMashedPotatoesEgg',
'SpecialHotdogBreadEggBacon',
'SpecialHotdogBreadEggCheese',
'SpecialHotdogBreadEggMashedPotatoesBacon',
'SpecialHotdogBreadEggPotatoSticks',
'SpecialHotdogBreadEggSausageMashedPotatoesBacon',
'SpecialHotdogBreadMashedPotatoesBacon',
'SpecialHotdogBreadMashedPotatoesCheese',
'SpecialHotdogBreadMashedPotatoesCheeseBacon',
'SpecialHotdogBreadMashedPotatoesEgg',
'SpecialHotdogBreadMashedPotatoesEggCheese',
'SpecialHotdogBreadMashedPotatoesEggPotatoSticks',
'SpecialHotdogBreadMashedPotatoesPotatoSticks',
'SpecialHotdogBreadMashedPotatoesPotatoSticksCheeseBacon',
'SpecialHotdogBreadMashedPotatoesPotatoSticksEggCheese',
'SpecialHotdogBreadPotatoSticksBacon',
'SpecialHotdogBreadPotatoSticksCheese',
'SpecialHotdogBreadPotatoSticksMashedPotatoesBacon',
'SpecialHotdogBreadPotatoSticksMashedPotatoesCheese',
'SpecialHotdogBreadSausageBacon',
'SpecialHotdogBreadSausageBaconCheese',
'SpecialHotdogBreadSausageBaconEggPotatoSticks',
'SpecialHotdogBreadSausageBaconPotatoSticks',
'SpecialHotdogBreadSausageCheese',
'SpecialHotdogBreadSausageCheeseBaconMashedPotatoesEgg',
'SpecialHotdogBreadSausageCheeseEggBacon',
'SpecialHotdogBreadSausageCheesePotatoSticksBaconEgg',
'SpecialHotdogBreadSausageCheesePotatoSticksBaconMashedPotatoesEgg',
'SpecialHotdogBreadSausageEgg',
'SpecialHotdogBreadSausageEggBacon',
'SpecialHotdogBreadSausageEggCheese',
'SpecialHotdogBreadSausageMashedPotatoes',
'SpecialHotdogBreadSausageMashedPotatoesBacon',
'SpecialHotdogBreadSausageMashedPotatoesCheese',
'SpecialHotdogBreadSausageMashedPotatoesEggCheese',
'SpecialHotdogBreadSausageMashedPotatoesPotatoSticks',
'SpecialHotdogBreadSausagePotatoSticks',
'SpecialHotdogBreadSausagePotatoSticksCheeseMashedPotatoesEgg',
'SpecialHotdogBreadSausagePotatoSticksMashedPotatoesCheese']
90
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment