Just build more housing lol.
Got to witness crabs doing this when going for a walk one day. There was a very shallow pool on the beach, about a foot wide, and about 20 crabs having a ‘swap meet’, scurrying back and fourth between the different shells.
That’s similar to how it works in Singapore, where housing is fully public
Sometimes matches would be arranged in triangles or other more complex shapes, but since everybody involved needed to get on the same page this was rare.
A web service could handle this neatly. You could commit to being ready for a match within the next 2 weeks. If the server can find a way to move any number of people between equivalent apartments, everyone gets notified and confirms receipt.
Humans could have this too if enough of us just started doing it