Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Distribucion de cortes
def length(sizes, goal): remainders = [] containers = [] container = [] fill = goal for size in sizes: qty = min(fill // size[0], size[1]) fill = fill - (qty * size[0]) remainders.append((size[0], size[1] - qty)) container.append((size[0], qty)) if any([size[1] for size in sizes]): containers = length(remainders, goal); else: return containers containers.append((container, fill)) return containers if __name__ == '__main__': sizes = [ (45.75, 10), # (MEDIDA DEL CORTE , CANTIDAD DE TUBOS) (13.75, 4), #SE AGREGA UN '(00 , 00), POR CADA CORTE NUEVO QUE SE HARA ] dist = list(reversed(length(sizes,156))) for elem in dist: print("Distribución de cortes: {} / Espacio restante en contenedor: {}".format(elem[0], elem[1]))
run
|
edit
|
history
|
help
0
Python: String to Brainfuck
number factor memoised
single inheritance
probl2_203700377
GMK output
hello
PyRegGreed
Myone
linked_lists_2
Test