Skip to content

Instantly share code, notes, and snippets.

@widdowquinn
Created April 30, 2019 15:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save widdowquinn/162d4846de6e331a3b301d5aad736c08 to your computer and use it in GitHub Desktop.
Save widdowquinn/162d4846de6e331a3b301d5aad736c08 to your computer and use it in GitHub Desktop.
Breakfast combinations
import seaborn
from itertools import combinations
def is_multiegg(breakfast):
if sum([1 in breakfast, 2 in breakfast, 3 in breakfast]) > 1:
return True
return False
# See Twitter:
# https://twitter.com/piglungs/status/1123228759803482112
# 14 items available for breakfast, and a breakfast has a minimum of three choices
# Three of these options are mutually exclusive (different kinds of egg), so we
# filter combinations on whether they contain *only one* of 1, 2 or 3
breakfasts = [x for sublist in [combinations(range(14), _)
for _ in range(3, 15)]
for x in sublist if not is_multiegg(x)]
print("Total number of single-egg-type breakfasts:", len(breakfasts))
seaborn.distplot([len(_) for _ in breakfasts], kde=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment