开发者

Iteration/Recursion problem?

I am working on a program where I have two 2d arrays. one is called males and one females. they're both 3x3 size. The array contains a score of how much a person likes the other.

i.e. (male array) This means that male0 likes female0 8, male0 likes female1 5, male0 likes female2 8, male1 likes female0 9, male1 likes female1 5, and so on....

    8 5 8
    9 5 7
    5 6 8

I also have another array like this for females where they rate the males.

Then a make another 2d array where I add the scores for each female(i,j) and male(i,j)

How do I go about finding out which combination gives the biggest total score? I would like to come up with something like

Best combination is:
male0 -> female2
male1 -> female0
male2 -> femal开发者_如何学Ce1


One way is to try every permutation of a female array, for each permutation finding the total score, and in the end picking the permutation that gives the highest score.


This is the Stable Marriage Problem

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜