update day 7 with recursive soln for part a

This commit is contained in:
Peter 2020-12-07 18:37:16 +08:00
parent 32cb11f3a9
commit 47b85b052b

13
7/b.py
View File

@ -21,4 +21,15 @@ def f(li,count):
count += k count += k
return count return count
print( f(dictionary['shiny gold'],0) ) print( f(dictionary['shiny gold'],0) ) #Part B
def g(li):
for u in li:
if u == 'shiny gold':
return True
else:
if g(dictionary[u]) == True:
return True
d = {x:g(dictionary[x]) for x in dictionary}
print(len({x for x in d if (d[x] == True)})) #Part A