Offset part outside if it's inside another part

How would i be able to offset the first part outside another if theyre touching/inside eachother?
I provided an example with 2 images
image1
image2