Browse Source

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

master
parent
commit
d26e10ca6f
  1. 31
      table_distributor.html

31
table_distributor.html

@ -45,12 +45,8 @@
<summary>Расстановка</summary> <summary>Расстановка</summary>
<div> <div>
<p> <p>
<label>Количество столов:</label> <label>Размеры столов (через запятую):</label>
<input id = "table_count" type="number" value="10" step="1" /> <input id = "table_size"/>
</p>
<p>
<label>Количество мест за столом:</label>
<input id = "table_size_count" type="number" value="5" step="1" />
</p> </p>
<textarea id="result_table_txt" cols="40" rows="5"></textarea> <textarea id="result_table_txt" cols="40" rows="5"></textarea>
</div> </div>
@ -252,23 +248,26 @@ def fill_tables():
tables = [] tables = []
cur_table_id = 0 cur_table_id = 0
table_count = int(document["table_count"].value) all_table_size = 0
table_size_count = int(document["table_size_count"].value) 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() beig_id_set = get_beig_id_set()
persons_set = set() persons_set = set()
while True: while len(persons_set) != len(persons):
if (len(persons_set) == len(persons)) or (len(persons_set) == (table_count * table_size_count)): if len(persons_set) >= all_table_size:
break break
new_person_id = 0 new_person_id = random.sample(list(beig_id_set - persons_set), 1)[0]
while True:
new_person_id = random.sample(list(beig_id_set), 1)[0]
if new_person_id not in persons_set:
break
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 persons_set = persons_set | cur_set
tables.append(Table(cur_table_id, cur_set)) tables.append(Table(cur_table_id, cur_set))
cur_table_id += 1 cur_table_id += 1

Loading…
Cancel
Save