Skip to main content
added 20 characters in body
Source Link
ElPedro
  • 6.5k
  • 2
  • 24
  • 38

Python 2, 120120 118 bytes

i,j=input()
a=j%i
n='|\n'
x='|'+'---'*i+n
print(x+('|'+'|x|'*(j%i)+''|'+'|x|'*a+' '*(i-j%ia)*3+n)*3,'')[j%i<1]+[a<1]+(x+('|'+'|x|'*i+n)*3)*(j/i)+x

Try it online!Try it online!

Have been meaning to have a go at this one for the last few days. Now that I have finally got time to do it there's already a shorter Python answer. Oh well, just posted as an alternative.

Input taken as width,books

Python 2, 120 bytes

i,j=input()
n='|\n'
x='|'+'---'*i+n
print(x+('|'+'|x|'*(j%i)+' '*(i-j%i)*3+n)*3,'')[j%i<1]+(x+('|'+'|x|'*i+n)*3)*(j/i)+x

Try it online!

Have been meaning to have a go at this one for the last few days. Now that I have finally got time to do it there's already a shorter Python answer. Oh well, just posted as an alternative.

Input taken as width,books

Python 2, 120 118 bytes

i,j=input()
a=j%i
n='|\n'
x='|'+'---'*i+n
print(x+('|'+'|x|'*a+' '*(i-a)*3+n)*3,'')[a<1]+(x+('|'+'|x|'*i+n)*3)*(j/i)+x

Try it online!

Have been meaning to have a go at this one for the last few days. Now that I have finally got time to do it there's already a shorter Python answer. Oh well, just posted as an alternative.

Input taken as width,books

Source Link
ElPedro
  • 6.5k
  • 2
  • 24
  • 38

Python 2, 120 bytes

i,j=input()
n='|\n'
x='|'+'---'*i+n
print(x+('|'+'|x|'*(j%i)+' '*(i-j%i)*3+n)*3,'')[j%i<1]+(x+('|'+'|x|'*i+n)*3)*(j/i)+x

Try it online!

Have been meaning to have a go at this one for the last few days. Now that I have finally got time to do it there's already a shorter Python answer. Oh well, just posted as an alternative.

Input taken as width,books