This gem provides a class for solving the Stable Marriage problem and Stable Roommates problem.
require 'shadchan' # stable marriage example shadchan = Shadchan::Shadchan.new [0, 2, 1], [2, 0, 1], [0, 2, 1], [1, 0, 2], [0, 2, 1], [0, 1, 2] shadchan.match #=> [[0, 2], [1, 0], [2, 1]] shadchan.match_men #=> [1, 2, 0] shadchan.match_women #=> [2, 0, 1] # stable roommates example roomie = Shadchan::Roomie.new [2,3,1,5,4],[5,4,3,0,2],[1,3,4,0,5],[4,1,2,5,0],[2,0,1,3,5],[4,0,2,3,1] roomie.match #=> [5,4,3,1,2,0]