title: Stacking boxes algorithm
body: <p><img src="https://i.stack.imgur.com/hxGjn.png" alt="enter image description here"></p>
  
  <p>I'm a little stuck trying to solve this problem. The main source of confusion comes from not knowing when to remove a box.</p>
  
  <p>Here's my approach:</p>
  
  <p>I look at the container column by column. If the top most box of the origin box is empty and the destination box is not empty, then i know to add that box. And  i know to remove the top box if its vice versa. I think that I have to swap when both positions have a box but are different. However my problem comes with certain cases where removing a box at the bottom will shift everything down and make it more like the destination box. Or maybe removing one in the center or removing two, one in the bottom and one in the center. How do I know when to remove a box? I can remove all combinations and see which makes it most close to the destination but that doesn't seem efficient.</p>
  
  <p>I also maybe think that this is an obvious dynamic programming problem thats going over my head. Any help would be appreciated</p>