68 lines
1.8 KiB
Python
68 lines
1.8 KiB
Python
import numpy as np
|
|
|
|
a = np.array([0, 1, 32 + 1, (32 + 1) * 16, 4, 5, 6, 7, 8, 8]).astype(np.uint32)
|
|
b = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 8]).astype(np.uint32)
|
|
|
|
|
|
d = np.ones(a.shape, dtype=np.uint32)
|
|
d = (d * 0xFFFFFFFF) << (b * 4)
|
|
|
|
c = a.astype(np.uint32)
|
|
|
|
cc = (
|
|
((c & 0xF) << 28)
|
|
+ ((c & 0xF0) << 20)
|
|
+ ((c & 0xF00) << 12)
|
|
+ ((c & 0xF000) << 4)
|
|
+ ((c & 0xF0000) >> 4)
|
|
+ ((c & 0xF00000) >> 12)
|
|
+ ((c & 0xF000000) >> 20)
|
|
+ ((c & 0xF0000000) >> 28)
|
|
)
|
|
cc = (cc >> ((8 - b) * 4)) + d
|
|
|
|
print(cc[3] == 4294963218)
|
|
|
|
b = np.ones((10)).astype(np.int32)
|
|
|
|
|
|
def get_tree_str_new(tree, prefix):
|
|
if isinstance(tree, dict):
|
|
base = ""
|
|
last_is_dict = None
|
|
for key, value in tree.items():
|
|
new_prefix = (len(str(key)) + 2) * " " + prefix
|
|
dict_string = get_tree_str_new(value, new_prefix)
|
|
if dict_string:
|
|
base += "\n" + prefix + str(key) + ": " + dict_string
|
|
last_is_dict = True
|
|
else:
|
|
base += "\n" + prefix + str(key) + " " if last_is_dict else str(key) + " "
|
|
last_is_dict = False
|
|
return base
|
|
return None
|
|
|
|
|
|
tree = {
|
|
112377: {
|
|
2944: {228: 228, 263: 263, 252: 252, 396: 396},
|
|
10024: {
|
|
1424: {189: 189, 209: 209, 200: 200, 102: 102, 178: 178, 22: 22, 9: 9},
|
|
1053: 432,
|
|
1350: {68: 68, 200: 200, 50: 50, 17: 17, 36: 36, 283: 283},
|
|
7: 7,
|
|
},
|
|
18196: 322,
|
|
13373: {
|
|
1420: {99: 99, 189: 189, 163: 163},
|
|
2109: {320: 320, 92: 92, 95: 95, 224: 224, 435: 435, 4: 4, 373: 373, 27: 27, 228: 228},
|
|
708: 708,
|
|
2196: {27: 27, 157: 157, 87: 87, 231: 231},
|
|
401: 401,
|
|
},
|
|
}
|
|
}
|
|
|
|
|
|
print(get_tree_str_new(tree, ""))
|