Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function makeCuboidsOfVolume(a,b,c,volume)
- local volume=volume or 4096
- local minLen=math.floor(volume^(1/3))
- local min=math.ceil(a/minLen)*math.ceil(b/minLen)*math.ceil(c/minLen)
- local solution={x=minLen,y=minLen,z=minLen,vol=volume,num=min}
- for x=1,math.min(a,volume) do
- for y=1,math.min(b,volume/x) do
- local z=math.floor(volume/(x*y))
- local num=math.ceil(a/x)*math.ceil(b/y)*math.ceil(c/z)
- if (num < min) then
- min=num
- solution={x=x,y=y,z=z,vol=x*y*z,num=min}
- end
- end
- end
- return solution
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement