mirror of
https://github.com/peter-tanner/advent-of-code-2020.git
synced 2024-11-30 10:50:17 +08:00
update day 7 with recursive soln for part a
This commit is contained in:
parent
32cb11f3a9
commit
47b85b052b
13
7/b.py
13
7/b.py
|
@ -21,4 +21,15 @@ def f(li,count):
|
|||
count += k
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue
Block a user