What you ask for is another problem.
The above simulation (in first message) calculated  center of mass for
1. the top block
2. two blocks from the top
3. three blocks from the top
and  all four blocks.