Created
March 1, 2019 11:56
-
-
Save japsu/6327f07f57aaab67b275f219fbd7561d to your computer and use it in GitHub Desktop.
mahdollisia hallituspohjia vihreän langan 02/2019 ennusteen pohjalta
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
from itertools import combinations | |
seats = dict(sdp=46, kok=38, kesk=34, vihr=27, pers=24, vas=16, rkp=8, kd=6) | |
assert sum(seats.values()) == 199 # ei ahvenanmaan 1 edustajaa | |
dislikes = [('kok', 'sdp'), ('kok', 'vas'), ('vihr', 'pers'), ('vas', 'pers'), ('pers', 'rkp')] | |
cabinets = [] | |
for num_parties in range(len(seats)): | |
cabinets.extend(combinations(seats.keys(), num_parties)) | |
cabinets_with_seats = [(sum(seats[party] for party in cabinet), cabinet) for cabinet in cabinets] | |
for seats, cabinet in sorted(cabinets_with_seats, reverse=True): | |
if seats >= 100 and not any(all(party in cabinet for party in dislike) for dislike in dislikes): | |
print(seats, *cabinet) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
137 sdp kesk vihr vas rkp kd | |
131 sdp kesk vihr vas rkp | |
129 sdp kesk vihr vas kd | |
123 sdp kesk vihr vas | |
121 sdp kesk vihr rkp kd | |
115 sdp kesk vihr rkp | |
113 sdp kesk vihr kd | |
113 kok kesk vihr rkp kd | |
110 sdp kesk vas rkp kd | |
110 sdp kesk pers kd | |
107 sdp kesk vihr | |
107 kok kesk vihr rkp | |
105 kok kesk vihr kd | |
104 sdp kesk vas rkp | |
104 sdp kesk pers | |
103 sdp vihr vas rkp kd | |
102 sdp kesk vas kd | |
102 kok kesk pers kd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment