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