假设任务是在3人之间划分33张表。如果等分,则输出为[11, 11, 11],如果表数为35个表,则输出应为[12, 12, 11]。
当我试图分裂时,我得到了[11, 11, 11, 1, 1]。我需要帮助在python中解决这个问题。这是我主要问题陈述的一部分。
这是我的代码:
div2 = count2 // len(ri_ot_curr) # equal division of other tables
rem2 = 0
rem2 = count2 % len(ri_ot_curr) # remaining tables tables unallocated
for i in range(len(ri_ot_curr)):
c = 0
for start in range(len(tft)):
if tft.loc[start, 'Release Date'] == 'Release '+str(release_date) a: #some condition
tft.loc[start, 'Quant RI - Table'] = ri_ot_curr[i]
tft.loc[start, 'Date'] = date_tft()
c = c+1
if c == div2:
break
if rem2 > 0:
ri_ot_rem = random.sample(ri_ot_curr, rem2)
for i in range(len(ri_ot_rem)):
for start in range(len(tft)):
if tft.loc[start, 'Release Date'] == 'Release '+str(release_date):#some condition
tft.loc[start, 'Quant RI - Table'] = ri_ot_rem[i]
tft.loc[start, 'Date'] = date_tft()
break发布于 2022-11-29 19:01:54
我希望我正确地理解了你,如果我这样做的话,这段代码就能做到这一点:
number_of_tables = 35
number_of_people = 3
tables_list = [int(number_of_tables / number_of_people) for _ in range(number_of_people)]
remainder = number_of_tables % number_of_people
for index in range(remainder):
tables_list[index] += 1
print(tables_list)https://stackoverflow.com/questions/74616430
复制相似问题