In the second, I guess it depends on if the server has a 16x16x1 brick.
But what about 8x16x1? what if the baseplate is supported by only one brick, in the corner?
Simple it would combine smaller bricks first then bigger bricks.
So 3 1x1f will morph in 1 x1 normal and then it will morph into a 1x2 with the other 1x1.
well, obviously. but what if the 1x1 stack next to it is offset by a plate?
that is one of the most basic of edge cases. here, lets try a few more:
1x2 next to stack of 1x10f plates next to a 1x6, all in a line. Which to replace? If 1x6, to form a 1x16, what happens if you encounter the 1x2 next to the 1x10f stack first, when iterating through the bricks to replace? How could you tell if there's a better replacement later? Is a bigger brick necessarily better?
1x2 in line with a 1x6, but next to a 1x3
(top down)
bbcccccc
aa
aa
aa
Which to replace? They're the same size, if you go by volume.
What if you have a 1x1f, on top is a 1x1. This is next to a 1x2. Do you detect that you can shift the brick on top down, replace it with a 1x3, and put a 1x1f on top?
these should be more than enough to illustrate how difficult this is.