ObliczanieMandatow
This commit is contained in:
parent
ea3997a05a
commit
7208c89ed6
33
obliczanieMandatow.py
Normal file
33
obliczanieMandatow.py
Normal file
@ -0,0 +1,33 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
class obliczanieMandatow(object):
|
||||
@staticmethod
|
||||
def test(komitety, glosy, mandaty):
|
||||
glosy_kopia = list(glosy)
|
||||
dzielniki_glosy = [ 1 for i in range(len(glosy_kopia)) ]
|
||||
while(mandaty != 0):
|
||||
index = 0
|
||||
max = glosy_kopia[0]
|
||||
for i in range(1,len(glosy_kopia)):
|
||||
if(glosy_kopia[i]>=max):
|
||||
if(glosy_kopia[i]==max):
|
||||
if(glosy[i]>glosy[index]):
|
||||
max = glosy_kopia[i]
|
||||
index = i
|
||||
else:
|
||||
max = glosy_kopia[i]
|
||||
index = i
|
||||
dzielniki_glosy[index] = dzielniki_glosy[index] + 1
|
||||
print glosy_kopia[index], '', komitety[index]
|
||||
glosy_kopia[index] = glosy[index] / dzielniki_glosy[index]
|
||||
mandaty = mandaty - 1
|
||||
|
||||
mandaty = 8
|
||||
list_glosy = [720, 300, 480]
|
||||
list_komitety = ['A', 'B', 'C']
|
||||
obliczanieMandatow.test(list_komitety, list_glosy, mandaty)
|
||||
|
||||
|
||||
"""
|
||||
|
||||
"""
|
Loading…
Reference in New Issue
Block a user