modification
This commit is contained in:
parent
7208c89ed6
commit
a799e7abc4
@ -1,10 +1,13 @@
|
||||
#!/usr/bin/python
|
||||
from ordynacja.models import Glos, Komitet
|
||||
|
||||
|
||||
class obliczanieMandatow(object):
|
||||
@staticmethod
|
||||
def test(komitety, glosy, mandaty):
|
||||
def dhondta(komitety, glosy, mandaty):
|
||||
glosy_kopia = list(glosy)
|
||||
dzielniki_glosy = [ 1 for i in range(len(glosy_kopia)) ]
|
||||
ilosc_mandatow = [ 0 for i in range(len(glosy_kopia)) ]
|
||||
while(mandaty != 0):
|
||||
index = 0
|
||||
max = glosy_kopia[0]
|
||||
@ -21,13 +24,20 @@ class obliczanieMandatow(object):
|
||||
print glosy_kopia[index], '', komitety[index]
|
||||
glosy_kopia[index] = glosy[index] / dzielniki_glosy[index]
|
||||
mandaty = mandaty - 1
|
||||
ilosc_mandatow[index] = ilosc_mandatow[index] + 1
|
||||
return ilosc_mandatow
|
||||
|
||||
mandaty = 8
|
||||
list_glosy = [720, 300, 480]
|
||||
list_komitety = ['A', 'B', 'C']
|
||||
obliczanieMandatow.test(list_komitety, list_glosy, mandaty)
|
||||
liczba_okregow = 41
|
||||
mandaty_w_okregach = [12,8,14,12,13,15,12,12,10,9,12,8,14,10,9,10,9,12,20,12,12,11,15,14,12,14,9,7,9,9,12,9,16,8,10,12,9,9,10,8,12]
|
||||
|
||||
for i in range(liczba_okregow):
|
||||
komitety = []
|
||||
liczba_glosow = []
|
||||
|
||||
"""
|
||||
|
||||
"""
|
||||
komitetyBaza = Komitet.objects().all()
|
||||
for j in KomitetBaza:
|
||||
komitety.append(j.name)
|
||||
glosy = Glos.objects().filter(okreg=i+1).order_by("kw_id")
|
||||
for g in glosy:
|
||||
liczba_glosow.append(g.liczba)
|
||||
obliczanieMandatow.dhondta(komitety, liczba_glosow, mandaty_w_okregach[i])
|
||||
|
Loading…
Reference in New Issue
Block a user