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:
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 ;-)
Find the longest sequence of 1's in a binary sequence.
2439 Solvers
Sum all integers from 1 to 2^n
6323 Solvers
Determine the number of odd integers in a vector
320 Solvers
98 Solvers
Integer sequence - 2 : Kolakoski sequence
81 Solvers