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