|
|
@@ -34,6 +34,7 @@ class Bag:
|
|
|
|
|
|
|
|
|
file = open('input.txt','r')
|
|
|
+#file = open('test.txt','r')
|
|
|
|
|
|
rules = file.readlines()
|
|
|
bags = []
|
|
|
@@ -75,6 +76,20 @@ def getToColor(target,start):
|
|
|
return True
|
|
|
return False
|
|
|
|
|
|
+def countSubBags(color):
|
|
|
+ sum = 0
|
|
|
+ bag = getBag(color)
|
|
|
+ if len(bag.getCapacity()) == 0:
|
|
|
+ return 1
|
|
|
+ for b in bag.getCapacity():
|
|
|
+ #print('['+color+'] '+ b[0] + ' * ' + str(countSubBags(b[1])))
|
|
|
+ sum += int(b[0]) * countSubBags(b[1])
|
|
|
+ print(color + ' ' +str(sum))
|
|
|
+ return sum + 1
|
|
|
+
|
|
|
+print(countSubBags('shiny gold') - 1)
|
|
|
+
|
|
|
+exit()
|
|
|
for b in bags:
|
|
|
if b.getColor() == 'shiny gold':
|
|
|
continue
|