Add: 10->12, 17
This commit is contained in:
37
2015/12.py
Normal file
37
2015/12.py
Normal file
@@ -0,0 +1,37 @@
|
||||
import json
|
||||
|
||||
# Fill Input
|
||||
|
||||
try:
|
||||
with open("12.txt", 'r', encoding='utf-8') as file:
|
||||
input = json.load(file)
|
||||
except Exception as e:
|
||||
print(f"An error occurred: {e}")
|
||||
|
||||
# Convert Corrdenate to string
|
||||
|
||||
def recursive_decend(json:any)->int:
|
||||
match json:
|
||||
case dict():
|
||||
sum = 0;
|
||||
for i in json:
|
||||
""" Part 2
|
||||
if json[i] == "red":
|
||||
return 0
|
||||
"""
|
||||
|
||||
sum += recursive_decend(json[i])
|
||||
return sum
|
||||
case list():
|
||||
sum = 0;
|
||||
for i in json:
|
||||
sum += recursive_decend(i)
|
||||
return sum
|
||||
case int():
|
||||
return json
|
||||
case str():
|
||||
return 0;
|
||||
|
||||
print(recursive_decend(input))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user