Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def make_statistics(results):
- exp_res = sorted(results)
- state2state_dict = {}
- for i in range(len(results)):
- if results[i][1] not in state2state_dict:
- state2state_dict[results[i][1]] = {}
- for j in range(len(results)):
- if results[j][1] not in state2state_dict[results[i][1]]:
- state2state_dict[results[i][1]][results[j][1]] = 0
- for i in results:
- k = exp_res.index(i)
- for j in range(k):
- state2state_dict[i[1]][exp_res[j][1]] += 1
- exp_res.remove(i)
- total = sum(sum(c.values()) for c in state2state_dict.values())
- return total, state2state_dict
- data = [(0, 'CZ'), (8, 'FR'), (4, 'EN'), (6, 'EN'), (5, 'CZ'), (3, 'EN'), (7, 'CZ'), (1, 'CZ'), (2, 'EN')]
- print(make_statistics(data))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement