Compare commits
2 Commits
bf896841d2
...
d7ef53e747
Author | SHA1 | Date | |
---|---|---|---|
d7ef53e747 | |||
34b9e54c0f |
@ -6,6 +6,7 @@ text: str = open("input.txt", "r").read()
|
|||||||
_value: int = 0
|
_value: int = 0
|
||||||
|
|
||||||
_lines = text.splitlines()
|
_lines = text.splitlines()
|
||||||
|
CHUNK_SIZE = 100000000
|
||||||
|
|
||||||
current_ranges = []
|
current_ranges = []
|
||||||
convertions = []
|
convertions = []
|
||||||
@ -39,7 +40,6 @@ for i, line in enumerate(_lines):
|
|||||||
if (line.endswith(" map:")):
|
if (line.endswith(" map:")):
|
||||||
convertions.append(extract_map_data(_lines[i + 1:]))
|
convertions.append(extract_map_data(_lines[i + 1:]))
|
||||||
|
|
||||||
|
|
||||||
current_time = time.time()
|
current_time = time.time()
|
||||||
def display_duration(interval_between_call, nb_total_values):
|
def display_duration(interval_between_call, nb_total_values):
|
||||||
global current_time
|
global current_time
|
||||||
@ -57,6 +57,8 @@ def get_min_in_range(lst_conversions, start, stop):
|
|||||||
min_value = do_all_convertions(lst_conversions, start)
|
min_value = do_all_convertions(lst_conversions, start)
|
||||||
i = start + 1;
|
i = start + 1;
|
||||||
while (i != stop):
|
while (i != stop):
|
||||||
|
if ((i - start) % 1000000 == 0):
|
||||||
|
print(f"{int((i - start)/(stop - start))}% ({i - start}/{stop - start})")
|
||||||
value = do_all_convertions(lst_conversions, i)
|
value = do_all_convertions(lst_conversions, i)
|
||||||
#print(min_value, value, min(value, min_value))
|
#print(min_value, value, min(value, min_value))
|
||||||
min_value = min(value, min_value)
|
min_value = min(value, min_value)
|
||||||
@ -69,8 +71,8 @@ def thread_process(convertions, start_value, chunk):
|
|||||||
global values
|
global values
|
||||||
values.append(get_min_in_range(convertions, start_value, chunk))
|
values.append(get_min_in_range(convertions, start_value, chunk))
|
||||||
|
|
||||||
CHUNK_SIZE = 10
|
|
||||||
for current_range in current_ranges:
|
for current_range in current_ranges:
|
||||||
|
print("new range")
|
||||||
start, stop = current_range
|
start, stop = current_range
|
||||||
i = start
|
i = start
|
||||||
chunks = []
|
chunks = []
|
||||||
@ -85,11 +87,14 @@ for current_range in current_ranges:
|
|||||||
while (i < len(chunks)):
|
while (i < len(chunks)):
|
||||||
t = threading.Thread(target=thread_process, args=(convertions, start_value, chunks[i]))
|
t = threading.Thread(target=thread_process, args=(convertions, start_value, chunks[i]))
|
||||||
t.start()
|
t.start()
|
||||||
display_duration(1, len(chunks))
|
print(f"start thread{i + 1}/{len(chunks)}")
|
||||||
print(i, '/', len(chunks))
|
|
||||||
i += 1
|
i += 1
|
||||||
start_value = chunks[i - 1]
|
start_value = chunks[i - 1]
|
||||||
|
|
||||||
|
while (threading.active_count() != 1):
|
||||||
|
print(values, threading.active_count() - 1)
|
||||||
|
time.sleep(10)
|
||||||
|
|
||||||
_value = min(values)
|
_value = min(values)
|
||||||
|
|
||||||
print(_value)
|
print(_value)
|
Loading…
Reference in New Issue
Block a user