Problem 2582. Cut an orange
Inspired by problem 2175.
A hungry matlab enthusiast has an orange. He decides to cut it into pieces using three dimensional grid.
Given grid density N please help him to find the number of ideal cubes full of juicy orange and the number of pieces containing also some peel.
Example: For N=3 matlab enthusiast is not satisfied. He gets [1 26]. Only one cube and 26 unpeeled pieces!
Related problems:
Solution Stats
Problem Comments
-
3 Comments
Perhaps I am misinterpreting, but it seems to me that some of your testsuite solutions are incorrect. For example, for N=5 I seem to be getting 19 instead of 27 cubes entirely within the sphere. I double-check using this code: x=rand(1e6,3); r=sum((x-.5).^2,2)<.25;
inside=accumarray(ceil(x*N),r);
outside=accumarray(ceil(x*N),~r) ;
disp([nnz(inside&~outside) nnz(inside&outside)]); Could you please let me know if I am misinterpreting, and if so which 8 additional cubes would you consider within the sphere?
You are totally right. I've generated answers using my solution, which was wrong. My fault is I haven't examined it any other way. Considering N=5, there could fit inside the sphere only a 3x3x3 cube, but its space diagonal is 3*sqrt(3) which is bigger than 5, the diameter of sphere. So, there cannot be more than 27-8=19 cubes inside. Thanks, for pointing that out, Alfonso!
Fixed & rescored now. It leads now to smaller-size answers. Consider the fact that for some N (for example 6) there are some quasi-cubes containing a very small amount of peel from those ultra-thin-peel-sweet-juicy-ideal-oranges ;-)
Solution Comments
Show commentsProblem Recent Solvers21
Suggested Problems
-
374 Solvers
-
Calculate the Number of Sign Changes in a Row Vector (No Element Is Zero)
720 Solvers
-
14735 Solvers
-
Finding neighbors of [-1:1] in a matrix....
75 Solvers
-
188 Solvers
More from this Author40
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!