Created
April 30, 2019 15:11
-
-
Save widdowquinn/162d4846de6e331a3b301d5aad736c08 to your computer and use it in GitHub Desktop.
Breakfast combinations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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