dsfdfw

Untitled

Jun 6th, 2024
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. 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]
  2. 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]
  3.  
  4. def modify_values(values, control):
  5. modified_values = values.copy()
  6. reduction = 0
  7. for i in range(len(control)):
  8. if control[i] == 1.0 and modified_values[i] > 0:
  9. for j in range(i, len(modified_values)):
  10. modified_values[j] = max(modified_values[j] - 1, 0)
  11. reduction += 1
  12. elif control[i] == 0.0 and i > 0 and control[i-1] == 1.0 and modified_values[i] > 0:
  13. for j in range(i, len(modified_values)):
  14. modified_values[j] = max(modified_values[j] - reduction, 0)
  15. reduction = 0
  16. return modified_values
  17.  
  18. final = modify_values(values, control)
  19. print(final)
Advertisement
Add Comment
Please, Sign In to add comment