one valid answer is 'EXUDING', 'GAWP', 'PALM' yet the function three_word_solution does not return this as an answer instead insists that 'EXUDING', 'GAWP', 'PALMING' is the only answer with 'GAWP' in it (I used a different word list but the error still stands)
the issue is caused due to the override that happens when multiple a and b instances satisfy the condition in the following dictionary creation:
solutions = {a:b for a in candidates for b in word_list if set(a+b)==chars and a[-1]==b[0]}
to address this a list should be used as values created for every solution key, and update vals to handle the multiple possible answers:
solutions = {}
for a in candidates:
for b in word_list:
if set(a+b) == chars and a[-1] == b[0]:
if a not in solutions:
solutions[a] = []
solutions[a].append(b)
...
vals = []
for e in ext:
if e[1] in solutions:
for c in solutions[e[1]]:
vals.append('-'.join([e[0], c]))
...
rest of the code remains the same, I tested this in a python notebook after extracting the solver function from the flask app, I will attach a pull request soon(tm) that will directly address this issue
example game: 'mna, leu, xdw, pig'
one valid answer is
'EXUDING', 'GAWP', 'PALM'
yet the functionthree_word_solution
does not return this as an answer instead insists that'EXUDING', 'GAWP', 'PALMING'
is the only answer with'GAWP'
in it (I used a different word list but the error still stands)the issue is caused due to the override that happens when multiple
a
andb
instances satisfy the condition in the following dictionary creation:to address this a list should be used as values created for every solution key, and update vals to handle the multiple possible answers:
rest of the code remains the same, I tested this in a python notebook after extracting the solver function from the flask app, I will attach a pull request soon(tm) that will directly address this issue