@@ -43,19 +43,29 @@ def find_matches(
4343 receivers_preferences : dict [int , list [int ]],
4444 ) -> dict [int , int ]:
4545 """
46- # add some tests
4746 >>> gs = GaleShapley()
48- >>> gs.find_matches({1: [1, 2, 3], 2: [2, 1, 3], 3: [2, 3, 1]}, {1: [1, 2, 3], 2: [2, 1, 3], 3: [2, 3, 1]})
47+ >>> gs.find_matches(
48+ ... {1: [1, 2, 3], 2: [2, 1, 3], 3: [2, 3, 1]},
49+ ... {1: [1, 2, 3], 2: [2, 1, 3], 3: [2, 3, 1]})
4950 {1: 1, 2: 2, 3: 3}
5051 >>> gs.find_matches({}, {})
5152 {}
52- >>> gs.find_matches({1: [1,]}, {1: [1,]})
53+ >>> gs.find_matches(
54+ ... {1: [1,]},
55+ ... {1: [1,]})
5356 {1: 1}
57+ >>> gs.find_matches(
58+ ... {1: [1, 2, 3, 4], 2: [1, 2, 3, 4], 3: [1, 2, 3, 4], 4: [1, 2, 3, 4]},
59+ ... {1: [4, 3, 2, 1], 2: [1, 2, 3, 4], 3: [2, 3, 4, 1], 4: [3, 4, 1, 2]})
60+ {1: 2, 2: 3, 3: 4, 4: 1}
61+ >>> gs.find_matches(
62+ ... {1: [2, 3, 4, 5, 6, 1], 2: [2, 4, 5, 6, 1, 3], 3: [4, 5, 6, 1, 2, 3], 4: [5, 6, 1, 2, 3, 4], 5: [2, 1, 6, 3, 4, 5], 6: [1, 2, 3, 4, 5, 6]},
63+ ... {1: [6, 1, 2, 3, 4, 5], 2: [1, 2, 3, 4, 5, 6], 3: [2, 3, 4, 5, 6, 1], 4: [3, 4, 5, 6, 1, 2], 5: [4, 5, 6, 1, 2, 3], 6: [5, 6, 1, 2, 3, 4]})
64+ {1: 2, 2: 3, 3: 4, 4: 5, 5: 6, 6: 1}
5465 """
5566
5667 matches = {key : - 1 for key in proposers_preferences .keys ()}
5768
58- # [NOTE] I would've used sets, but want replicability for easy debugging.
5969 free_proposers = list (proposers_preferences .keys ())
6070 tested_matches = {key : 0 for key in proposers_preferences .keys ()}
6171
0 commit comments