Skip to content

Instantly share code, notes, and snippets.

@chrysmur
Last active April 23, 2021 20:12
Show Gist options
  • Save chrysmur/03681d97a414af6d587e1f83820ccaed to your computer and use it in GitHub Desktop.
Save chrysmur/03681d97a414af6d587e1f83820ccaed to your computer and use it in GitHub Desktop.
umbrella Challenge
def umbrella_count(people, umbrellas, store={}):
if people in store: return store[people]
if people < 0: return None
if people == 0: return []
shortest = None
for umb in umbrellas:
remainder = people - umb
result = umbrella_count(remainder, umbrellas, store)
if result is not None:
combination =[*result, umb]
store[people] = combination
if not shortest or (len(shortest) > len(combination)):
shortest = combination
return shortest
def solution(people, umbrellas):
count = umbrella_count(people, umbrellas)
print(count)
if count: return len(count);
else: return -1
@Crownedprinz
Copy link

wow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment