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 commentsGroup

Indexing III
- 23 Problems
- 44 Finishers
- expand intervals vol.3
- remove single elements
- return row and column indices given 2 values which define a range
- expand intervals vol.2
- compress sequence into intervals
- expand intervals
- Max Change in Consecutive Elements
- remove single elements
- Back to basics - mean of corner elements of a matrix
- Time Expansion
- Three...is a magic number.
- counting groups!
- Largest territory
- Replace pattern 0 1 0 and 1 0 1
- Find the index of n in magic(n)
- Sum of odd numbers in a matrix
- return row and column indices given 2 values which define a range
- Another colon problem
- How unique?
- Finding neighbors of [-1:1] in a matrix....
- Find the maximum two numbers of every column of a matrix
- Index one element in each vector of an array along a given dimension
- Tridiagonal
- Index of a Rational number
- Sort numbers by outside digits
Problem Recent Solvers21
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!