Thank you for the kind words. Your approach is mostly right, but your approach to the second step is a bit different from how I'd describe it - think about other ways to move hats to get to your desired order.
The key is to support the blue hat so there's room to slide green under the blue, rather than put blue on top of green.