Browse Source

Поле размеры столов #4

master
parent
commit
d26e10ca6f
  1. 35
      table_distributor.html

35
table_distributor.html

@ -45,12 +45,8 @@
<summary>Расстановка</summary>
<div>
<p>
<label>Количество столов:</label>
<input id = "table_count" type="number" value="10" step="1" />
</p>
<p>
<label>Количество мест за столом:</label>
<input id = "table_size_count" type="number" value="5" step="1" />
<label>Размеры столов (через запятую):</label>
<input id = "table_size"/>
</p>
<textarea id="result_table_txt" cols="40" rows="5"></textarea>
</div>
@ -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

Loading…
Cancel
Save