Skip to content

vsalbaba/Shadchan

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Shadchan

This gem provides a class for solving the Stable Marriage problem and Stable Roommates problem.

Installation
gem install shadchan

Usage

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]

About

Class solving stable marriage problem

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages