From d26e10ca6f08c4579ef89c19eece3038638c39e2 Mon Sep 17 00:00:00 2001 From: Alexei Bezborodov Date: Fri, 28 Oct 2022 16:16:23 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=BB=D0=B5=20=D1=80=D0=B0=D0=B7?= =?UTF-8?q?=D0=BC=D0=B5=D1=80=D1=8B=20=D1=81=D1=82=D0=BE=D0=BB=D0=BE=D0=B2?= =?UTF-8?q?=20#4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- table_distributor.html | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/table_distributor.html b/table_distributor.html index 9b09f6d..06ef9bc 100755 --- a/table_distributor.html +++ b/table_distributor.html @@ -45,12 +45,8 @@ Расстановка

- - -

-

- - + +

@@ -252,23 +248,26 @@ def fill_tables(): tables = [] cur_table_id = 0 - table_count = int(document["table_count"].value) - table_size_count = int(document["table_size_count"].value) - + all_table_size = 0 + str_table_size = document["table_size"].value.replace(" ", "").split(",") + table_size = [] + for s in str_table_size: + if len(s) != 0: + t = int(s) + all_table_size += t + table_size += [t] + + table_count = len(table_size); beig_id_set = get_beig_id_set() persons_set = set() - while True: - if (len(persons_set) == len(persons)) or (len(persons_set) == (table_count * table_size_count)): + while len(persons_set) != len(persons): + if len(persons_set) >= all_table_size: break - new_person_id = 0 - while True: - new_person_id = random.sample(list(beig_id_set), 1)[0] - if new_person_id not in persons_set: - break + new_person_id = random.sample(list(beig_id_set - persons_set), 1)[0] - cur_set = fill_next_table(new_person_id, persons_set, min(table_size_count, len(persons) - len(persons_set))) + cur_set = fill_next_table(new_person_id, persons_set, min(table_size[cur_table_id], len(persons) - len(persons_set))) persons_set = persons_set | cur_set tables.append(Table(cur_table_id, cur_set)) cur_table_id += 1 @@ -276,7 +275,7 @@ def fill_tables(): def fill_persons(): global persons global tables - for t in tables: + for t in tables: for p in persons: if p.beig_id in t.person_set: p.meet_set = t.person_set | p.meet_set