updated
This commit is contained in:
@@ -17,14 +17,14 @@ def p1():
|
||||
for element in sample[1:]:
|
||||
if 'no' in element:
|
||||
continue
|
||||
data.append(element.split(' ', 1))
|
||||
data.append(tuple(element.split(' ', 1)))
|
||||
pwd[sample[0]] = data
|
||||
|
||||
@functools.lru_cache(maxsize=256)
|
||||
def contains_gold(y):
|
||||
return 'shiny gold' == y or any(map(lambda x: contains_gold(x[1]), pwd[y]))
|
||||
|
||||
s = sum(map(lambda x: any(map(lambda x: contains_gold(x[1]), pwd[x])), pwd))
|
||||
s = sum(map(lambda x: any(map(lambda y: contains_gold(y[1]), pwd[x])), pwd))
|
||||
|
||||
|
||||
print(s)
|
||||
@@ -53,12 +53,12 @@ def p2(r):
|
||||
if part_one():
|
||||
start = time.time()
|
||||
result1 = p1()
|
||||
print(round(time.time() - start, 6), 's')
|
||||
print(round(1000*(time.time() - start), 2), 'ms')
|
||||
|
||||
|
||||
if part_two():
|
||||
start = time.time()
|
||||
p2(result1)
|
||||
print(round(time.time() - start, 6), 's')
|
||||
print(round(1000*(time.time() - start), 2), 'ms')
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user