Advertisement
Guest User

Untitled

a guest
Dec 12th, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. def make_statistics(results):
  2. exp_res = sorted(results)
  3. state2state_dict = {}
  4. for i in range(len(results)):
  5. if results[i][1] not in state2state_dict:
  6. state2state_dict[results[i][1]] = {}
  7. for j in range(len(results)):
  8. if results[j][1] not in state2state_dict[results[i][1]]:
  9. state2state_dict[results[i][1]][results[j][1]] = 0
  10.  
  11. for i in results:
  12. k = exp_res.index(i)
  13. for j in range(k):
  14. state2state_dict[i[1]][exp_res[j][1]] += 1
  15. exp_res.remove(i)
  16.  
  17. total = sum(sum(c.values()) for c in state2state_dict.values())
  18.  
  19. return total, state2state_dict
  20.  
  21. data = [(0, 'CZ'), (8, 'FR'), (4, 'EN'), (6, 'EN'), (5, 'CZ'), (3, 'EN'), (7, 'CZ'), (1, 'CZ'), (2, 'EN')]
  22. print(make_statistics(data))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement