Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from collections import deque
- from math import inf
- def best_list_pureness(user_list, num):
- user_list = deque(user_list)
- best_pureness = sum(value * idx for idx, value in enumerate(user_list))
- best_turn = 0
- for rotation in range(1, num):
- current_pureness = sum(value * idx for idx, value in enumerate(user_list))
- if current_pureness > best_pureness:
- best_pureness = current_pureness
- best_turn = rotation
- user_list.rotate()
- return f"Best pureness {best_pureness} after {best_turn} rotations"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement