Sunday, October 16, 2016

Puzzlor Matchup

PuzzlOR_Matchup
In [1]:
from itertools import permutations
Personality Characteristics Key:
  1. L=Liberal, C=Conservative
  2. C=Chess, R=Running
  3. R=Rural, U=Urban
  4. O=Outgoing, I=Introverted
In [2]:
men = ["LRRI", "LCRO", "CRUI", "LRRI", "CRRI", "CCRI", "CCUI", "LCUI", "LRUI", "LRUO"]
women = ["CCRI", "LRRI", "CCRO", "CRUO", "CCUO", "LRUI", "CCUO", "CRUO", "LCUI", "LRRI"]
In [3]:
def matching(M, W):
    score = 0
    if M[0] == W[0]:
        score = score + 1
    if M[1] == W[1]:
        score = score + 1
    if M[2] == W[2]:
        score = score + 1
    if M[3] == W[3]:
        score = score + 1   
    return score
In [4]:
best_score = 0

for config in permutations([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]):
    score = 0
    for m, w in zip(range(10), config):
        score += matching(men[m], women[w])

    if score > best_score:
        best_score = score
        print(config, best_score)
(0, 1, 2, 3, 4, 5, 6, 7, 8, 9) 17
(0, 1, 2, 3, 4, 5, 6, 8, 7, 9) 19
(0, 1, 2, 3, 4, 5, 6, 8, 9, 7) 21
(0, 1, 2, 3, 4, 9, 6, 8, 5, 7) 23
(0, 1, 2, 3, 9, 4, 6, 8, 5, 7) 25
(0, 1, 2, 9, 3, 4, 6, 8, 5, 7) 27
(0, 1, 3, 9, 2, 4, 6, 8, 5, 7) 29
(0, 2, 3, 1, 9, 4, 6, 8, 5, 7) 31
(1, 2, 3, 9, 0, 4, 6, 8, 5, 7) 33

The maximum number of points that can be achieved is 33, with the following matches:

  • Man 1 <--> Woman 2
  • Man 2 <--> Woman 3
  • Man 3 <--> Woman 4
  • Man 4 <--> Woman 10
  • Man 5 <--> Woman 1
  • Man 6 <--> Woman 5
  • Man 7 <--> Woman 7
  • Man 8 <--> Woman 9
  • Man 9 <--> Woman 6
  • Man 10 <--> Woman 8