PY
py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Inspiree by Sarah's question: https://www.sololearn.com/Discuss/3181320/?ref=app
# Includes a test code that shows a way to have the model poorly constructed near the bottom
def calc_expedit(kallax):
# dimension = ("33 - 39cm")
width = 33.0 # total inner size
height = width
depth = width
thickness = 1.5
rows = len(kallax)
cols = max(map(lambda row: sum(row), kallax))
printLen = 3
s = ''
slotNo = 0
print('-'*(cols*printLen+1))
extraRow = 0
for r in range(len(kallax)):
print(end='|')
for c in range(len(kallax[r])):
slotNo += 1
if r > 0:
while sum(kallax[r][:c+1]) > sum(kallax[r-1-extraRow]) or extraRow > 0 and sum(kallax[r][:c+1]) > sum(kallax[r-1-extraRow]):
extraRow += 1
print(f'{str(slotNo).center(kallax[r][c]*printLen-1)}', end='|')
h = (height-(rows-1)*thickness)*(1+extraRow)/rows+extraRow*thickness
w = (width-(cols-1)*thickness)*kallax[r][c]/cols+(kallax[r][c]-1)*thickness
s += f'Slot{slotNo:>2}: h:{round(h,3)}\tw:(){round(w,3)}\td:{depth}\n'
if sum(kallax[r]) == cols:
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run