Advertisement
Rad_Carrie

Untitled

Apr 25th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.04 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. from copy import copy
  3. from random import randint
  4.  
  5.  
  6. def get_random_index(list):
  7.     return randint(0, len(list) - 1)
  8.  
  9. def print_students(dict):
  10.     for student in dict.keys():
  11.         print('Студент: ' + student)
  12.         print('Ревьюеры: ' + ', '.join(dict[student]))
  13.  
  14. team_1 = ['avoronova', 'nneborskaya', 'nspiridonova', 'kivyanskaya', 'azinina', 'otolokolnikova', 'ezorina']
  15. team_2 = ['aseleverstov', 'anovoselov', 'abrazhnikov', 'ddanilov', 'mgrischenko', 'vgvarianashvili', 'mkochetkova']
  16. my_dict = {}
  17. team_1_reviewers = copy(team_1)
  18.  
  19. for person in team_1:
  20.     reviewer_1 = None
  21.     index = -1
  22.     while not reviewer_1 or person == reviewer_1:
  23.         if len(team_1_reviewers) != 2 or team_1[-1] not in team_1_reviewers:
  24.             index = get_random_index(team_1_reviewers)
  25.         reviewer_1 = team_1_reviewers[index]
  26.  
  27.     reviewer_1 = team_1_reviewers.pop(index)
  28.  
  29.     reviewer_2 = team_2.pop(get_random_index(team_2))
  30.     my_dict[person] = (reviewer_1, reviewer_2)
  31. print_students(my_dict)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement