From 7208c89ed6bce71d9b49179297b343a4e6c7b44a Mon Sep 17 00:00:00 2001 From: czup Date: Sat, 30 Jun 2018 10:33:00 +0200 Subject: [PATCH] ObliczanieMandatow --- obliczanieMandatow.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 obliczanieMandatow.py diff --git a/obliczanieMandatow.py b/obliczanieMandatow.py new file mode 100644 index 0000000..060ade0 --- /dev/null +++ b/obliczanieMandatow.py @@ -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) + + +""" + +""" \ No newline at end of file