Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- control = [0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0]
- values =[0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 3.0]
- def modify_values(values, control):
- modified_values = values.copy()
- reduction = 0
- for i in range(len(control)):
- if control[i] == 1.0 and modified_values[i] > 0:
- for j in range(i, len(modified_values)):
- modified_values[j] = max(modified_values[j] - 1, 0)
- reduction += 1
- elif control[i] == 0.0 and i > 0 and control[i-1] == 1.0 and modified_values[i] > 0:
- for j in range(i, len(modified_values)):
- modified_values[j] = max(modified_values[j] - reduction, 0)
- reduction = 0
- return modified_values
- final = modify_values(values, control)
- print(final)
Advertisement
Add Comment
Please, Sign In to add comment