Mrs. Froopaloop has invited several wives of delegates to the United Nations for an informal luncheon. She plans to seat her 9 guests in a row such that each lady will be able to converse with the person directly to her left and right.
She has prepared the following list:
Mrs. Froopaloop speaks only English.
Mrs. Garot speaks English and French.
Mrs. Hakobyan speaks English and Russian.
Mrs. Jumaev speaks Russian only.
Mrs. Kelly speaks English only.
Mrs. Lafourcade speaks French only.
Mrs. Mendler speaks French and German.
Mrs. Nabe speaks English and German.
Mrs. Olson speaks English only.
How many distinct seating arrangements are possible?
Note that ABCD and DCBA are the same.
I found 126 solutions not counting mirror image reversals.
-----
d = {'F': 'e',
'G': 'ef',
'H': 'er',
'J': 'r',
'K': 'e',
'L': 'f',
'M': 'fg',
'N': 'eg',
'O': 'e'}
ladies = d.keys()
sols = []
from itertools import permutations
for perm in permutations(ladies):
winner = True
for i,p in enumerate(perm):
if i == 0:
continue
a = d[p]
b = d[perm[i-1]]
if len(set(a+b)) == len(a) + len(b):
winner = False
break
if winner:
winstring = ''.join(perm)
if winstring[0] < winstring[-1]:
sols.append(winstring)
print(winstring)
print(len(sols))
-----
FGLMNKOHJ
FGLMNOKHJ
FKGLMNOHJ
FKNMLGOHJ
FKOGLMNHJ
FKONMLGHJ
FNMLGKOHJ
FNMLGOKHJ
FOGLMNKHJ
FOKGLMNHJ
FOKNMLGHJ
FONMLGKHJ
GLMNFKOHJ
GLMNFOKHJ
GLMNKFOHJ
GLMNKOFHJ
GLMNOFKHJ
GLMNOKFHJ
JHFGKONML
JHFGLMNKO
JHFGLMNOK
JHFGOKNML
JHFKGLMNO
JHFKGONML
JHFKNMLGO
JHFKNOGLM
JHFKNOGML
JHFKOGLMN
JHFKOGNML
JHFKONGLM
JHFKONGML
JHFKONMGL
JHFNKOGLM
JHFNKOGML
JHFNMLGKO
JHFNMLGOK
JHFNOKGLM
JHFNOKGML
JHFOGKNML
JHFOGLMNK
JHFOKGLMN
JHFOKGNML
JHFOKNGLM
JHFOKNGML
JHFOKNMGL
JHFONKGLM
JHFONKGML
JHFON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