Stable marriage problem
Mathematica, 28 bytes

On would think, this is cheating. I for myself like this:

Combinatorica`StableMarriage



Needs to be called with the weight matrices of the preferences for
men and women.
Returns the direct indizes for the coupling.


(Yes Combinatorica is deprecated but it costs fewer bytes than FindIndependentEdgeSet)



Example (GoT-like):
(To be fair - i guessed the weights...but i'm okay with the results)



m = {{2, 4, 3, 1}, {1, 2, 4, 3}, {3, 2, 1, 4}, {4, 2, 1, 3}};
w = {{2, 3, 4, 1}, {3, 2, 1, 4}, {3, 2, 4, 1}, {4, 1, 2, 3}};
result = Combinatorica`StableMarriage[w, m];
MapThread[
  UndirectedEdge[Show[#1, ImageSize -&gt; 130], 
    Show[#2, ImageSize -&gt; 130]] &amp;, {names1, 
   names2[[result]]}] // TableForm