# Difference from liquid to solid items

A shape's volume is the measure of how much three-dimensional space that shape occupies.

# Challenge

Given six integers: [L,W,H] as length, width and height of one container and [l,w,h] as length, width and height of some random item.

You will need to calculate how many items would fit completely if the item was a liquid/fluid... and subtract how many items would also fit completely if the item was solid.

Note: Rotating the solid shape to fit empty space is required.

The input can be read from stdin, taken from args, can also be one or two lists/arrays, or any other valid way, but you can take in only six integers.

And the output should be one integer number: the difference.

Whole program or function are accepted.

Since this is shortest code in bytes wins!

# Sample Input/Output

1) L=3  W=2  H=2  l=1  w=1  h=2
-> for item as liquid : 6 items fit completely
-> for item as solid  : 6 items fit completely
output: 0

2) L=1  W=8  H=3  l=3  w=4  h=2
-> for item as liquid : 1 item fit completely
-> for item as solid  : no items fit completely
output: 1

3) L=3  W=4  H=3  l=2  w=2  h=2
-> for item as liquid : 4 items fit completely
-> for item as solid  : 2 items fit completely
output: 2

4) L=6  W=6  H=6  l=1  w=5  h=6
-> for item as liquid : 7 items fit completely
-> for item as solid  : 7 items fit completely
output: 0


# Draws

Just for illustration of how the solid items could fit:

### Sample #4

• Do we have to consider rotations of the items? – PurkkaKoodari Mar 9 '16 at 4:46
• The solid version effectively has things like en.wikipedia.org/wiki/… as a subproblem. So even ignoring the golfing getting this correct at all is potentially VERY hard. See also en.wikipedia.org/wiki/Cutting_stock_problem – Ton Hospel Mar 9 '16 at 13:40
• Do you mean that each of the smaller solids (that, I suppose, are aproximated as cuboids) may be rotated independently to achieve optimal ocupancy of the larger solid? If so, it seems like a formidable math problem by itself. – dnep Mar 9 '16 at 14:12
• Ok, with out of alignment rotations allowed too I don't even see a way to do an exponential complexity exhaustive search anymore – Ton Hospel Mar 9 '16 at 18:01
• @feersum Wow, this is wicked! – dnep Mar 10 '16 at 14:40

## Python 2.7 - 659548373 355 bytes

My first golf, but still very golfable.

The rotation thing didn't make it as easy as expected though.

import numpy as n
L,W,H,l,w,h=input();bx=n.zeros((L,W,H));s=0
q=(L*W*H)//(l*w*h);o=[[l,w,h],[l,h,w],[w,l,h],[w,h,l],[h,l,w],[h,w,l]];p=n.ndindex
for i in range(q):
for a,b,c in p(L,W,H):
for k in o:
d=n.copy(bx)
try:
for x,y,z in p(k[0],k[1],k[2]):
if d[a+x][b+y][c+z]:raise
d[a+x][b+y][c+z]=1
s+=1;bx=d
except:pass
print q-s


But still a nice little brainteaser :D

**Edit: My colleague and I pondered a little more, and we found some more optimization potential

**Saved 18 byte thanks to CatsAreFluffy

Examples:

[6,6,6,1,5,6]
0

[3,4,3,2,2,2]
2

• Welcome to Programming Puzzles & Code Golf! Answers to code-golf challenges are required to be at least trivially golfed. You already used singler letter variables, which is good, but you should also remove unnecessary whitespaces between operators. Also you can write multiple statements in one line if you seperate them with a ; which saves you the newlines and the potential intendation whitespaces. – Denker Mar 9 '16 at 12:18
• Also you only need to output one integer. There is no need to add text to it, this only increases your byte count for no reason. – Denker Mar 9 '16 at 12:31
• Ty DenkerAffe, the edits saved some bytes :D – Kijata Mar 9 '16 at 12:35
• You can save a few bytes by defining a new range() and product() function as a one-letter function like so: r=range and p=product. You can now call range() as just r() and product() as just p()! This is a pretty good tip for built-in functions that are used many times throughout a golf. – MrPublic Mar 9 '16 at 12:38
• Something like this. – ASCII-only Mar 9 '16 at 13:34