-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path11.py
94 lines (65 loc) · 1.64 KB
/
11.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import math
import collections
from collections import Counter
import re
from tqdm import tqdm
PROD = """
1 24596 0 740994 60 803 8918 9405859
"""
TEST = """
125 17
"""
TEST2 = """
"""
x = TEST
x = PROD
x = x.strip()
# Data in differnt formats for quick access
text = x
lines = x.split("\n")
grid = [list(line) for line in lines]
numssss = text.split()
numssss = [int(x) for x in numssss]
s = 0
seen = set()
# for num in numssss:
# curr = [num]
# for _ in tqdm(range(25)):
# new = []
# for num in curr:
# # print(new)
# if num == 0:
# new.append(1)
# elif len(str(num)) % 2 == 0:
# left = str(num)[: len(str(num)) // 2]
# right = str(num)[len(str(num)) // 2 :]
# new.append(int(left))
# new.append(int(right))
# else:
# new.append(num * 2024)
# for n in new:
# if n in seen:
# print("SEEN THIS BEFORE", n)
# seen.add(n)
# curr = new
# s += len(curr)
from functools import cache
@cache
def process_number(num, depth=75):
if depth == 0:
return 1
if num == 0:
return process_number(1, depth - 1)
if len(str(num)) % 2 == 0:
left = str(num)[: len(str(num)) // 2]
right = str(num)[len(str(num)) // 2 :]
return process_number(int(left), depth - 1) + process_number(
int(right), depth - 1
)
return process_number(num * 2024, depth - 1)
for num in numssss:
results = process_number(num)
# print(results)
s += results
print(s)
# print(len(nums))