opti use simple operation
This commit is contained in:
parent
d7ef53e747
commit
23a9d663e4
@ -23,17 +23,16 @@ def extract_map_data(lines: [str]):
|
|||||||
if (line == ""):
|
if (line == ""):
|
||||||
break
|
break
|
||||||
bozo = line.split()
|
bozo = line.split()
|
||||||
|
destination = int(bozo[0])
|
||||||
|
source_start = int(bozo[1])
|
||||||
length = int(bozo[2])
|
length = int(bozo[2])
|
||||||
destination = int(bozo[0]) - int(bozo[1])
|
lst.append([destination - source_start, source_start, source_start + length])
|
||||||
source_range = range(int(bozo[1]), int(bozo[1]) + length)
|
|
||||||
lst.append({"destination": destination, "source_range": source_range})
|
|
||||||
return lst
|
return lst
|
||||||
|
|
||||||
def translation(lst: list[dict], value: int):
|
def translation(lst: list[[]], value: int):
|
||||||
for map in lst:
|
for dst, src_start, src_stop in lst:
|
||||||
if value in map["source_range"]:
|
if src_start <= value <= src_stop:
|
||||||
value += map["destination"]
|
return(value + dst)
|
||||||
break
|
|
||||||
return value
|
return value
|
||||||
|
|
||||||
for i, line in enumerate(_lines):
|
for i, line in enumerate(_lines):
|
||||||
@ -48,7 +47,7 @@ def display_duration(interval_between_call, nb_total_values):
|
|||||||
diff = int(((current_time - old_time) / interval_between_call) * nb_total_values)
|
diff = int(((current_time - old_time) / interval_between_call) * nb_total_values)
|
||||||
print(f"{int(diff / 3600)}h {int(diff % 3600 / 60)}min {int(diff % 60)}s")
|
print(f"{int(diff / 3600)}h {int(diff % 3600 / 60)}min {int(diff % 60)}s")
|
||||||
|
|
||||||
def do_all_convertions(lst_convertions: [[dict]], value):
|
def do_all_convertions(lst_convertions: [[[]]], value):
|
||||||
for i, tab_convertion in enumerate(convertions):
|
for i, tab_convertion in enumerate(convertions):
|
||||||
value = translation(tab_convertion, value)
|
value = translation(tab_convertion, value)
|
||||||
return value
|
return value
|
||||||
@ -58,9 +57,8 @@ def get_min_in_range(lst_conversions, start, stop):
|
|||||||
i = start + 1;
|
i = start + 1;
|
||||||
while (i != stop):
|
while (i != stop):
|
||||||
if ((i - start) % 1000000 == 0):
|
if ((i - start) % 1000000 == 0):
|
||||||
print(f"{int((i - start)/(stop - start))}% ({i - start}/{stop - start})")
|
print(f"{int((i - start) * 100/(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))
|
|
||||||
min_value = min(value, min_value)
|
min_value = min(value, min_value)
|
||||||
i += 1
|
i += 1
|
||||||
return (min_value)
|
return (min_value)
|
||||||
@ -95,6 +93,7 @@ while (threading.active_count() != 1):
|
|||||||
print(values, threading.active_count() - 1)
|
print(values, threading.active_count() - 1)
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
|
|
||||||
|
print(values)
|
||||||
_value = min(values)
|
_value = min(values)
|
||||||
|
|
||||||
print(_value)
|
print(_value)
|
Loading…
Reference in New Issue
Block a user