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