The most common solution in a divorce is to sell the house and split the profits. It’s common to split the profits 50/50, but that can change due to a myriad of reasons like a pre-nuptial agreement, one party wants to keep their retirement account in place, etc.
If one person wants to stay in the house, it’s possible to buy the other person out, as long as they can do it financially. First, both parties have to agree on a price, which is not a foregone conclusion. They can have it appraised but one party may feel the appraisal is too high (or too low). Then the party that’s remaining has to be able to put their hands on enough cash to buy the departing party out.