Forum Discussion
Lookup five characters appearing in any order in a wordlist
Worn out!
- mhlesterJul 09, 2023Copper Contributor
Don't blame you! I can't let it go, yet. I want to find all the instances of matching pairs that are in my dictionary...
- mhlesterJul 10, 2023Copper Contributor
I was finally able to make Filter work to find all possible matches for all legal words with this formula.
=IFERROR(TRANSPOSE(FILTER($A$2:$A$3570,ISNUMBER(SEARCH(AA451,$F$2:$F$3570)))),"")
The word in column AH in the sheet snippet below is the first word to solve the puzzle and the words in columns AI, AJ, et. seq. are candidates for the second word.
I could not figure out how to make the formula return only words that start with the last letter of AH or end with the first letter of AH. Only the words highlighted in yellow in cells AI, AJ, et. seq., in the sheet below (a small snippet of the full list) solve the problem.
Will someone please help me revise the formula to only find legal words (in AI, AJ, et. seq.) that start with the last letter of the first word (AH) or end with the first letter of the first word (AH)?
Addendum:
=FILTER($AK$451:$JL$451,RIGHT($AK$451:$JL$451,LEN(AI451))=AI451,”No Results!”)
This filter would filter the results of the above filter to find only the words that end with the first letter of the first word. So, I am part way there. I just need to add the filter that also finds any words that start with the last letter of the first word. Maybe these filters could be nested? That would be it, I think.
- PeterBartholomew1Jul 10, 2023Silver Contributor
The formula used in the solution I posted above was
... firstWord, TOCOL(IF(allChar=maxChar, legalList, NA()), 3), secondWord, TOCOL(IF(allChar=maxChar, TRANSPOSE(legalList), NA()), 3), FILTER(HSTACK(firstWord, secondWord), RIGHT(firstWord, 1) = LEFT(secondWord, 1))
The next task would be to optimise the formula to improve performance.
For example, I checked every character within a Scrabble word to see whether it was drawn from the Square. Had I followed your suggestion and checked for the occurrence of other characters, then recursion would allow one to bail out before the whole word is validated.
- mhlesterJul 11, 2023Copper Contributor
Unfortunately, I don't know how to implement your formula, but on the plus side... I got it to work, finally, with a nested filter and an "or" function. I kept making little errors in the formula, which is why it wasn't working. And then I would try another approach, and another...
=FILTER(IFERROR(TRANSPOSE(FILTER($A$2:$A$3528,ISNUMBER(SEARCH(AA57,$F$2:$F$3528)))),""),(RIGHT(IFERROR(TRANSPOSE(FILTER($A$2:$A$3528,ISNUMBER(SEARCH(AA57,$F$2:$F$3528)))),""),1)=I57)+(LEFT(IFERROR(TRANSPOSE(FILTER($A$2:$A$3528,ISNUMBER(SEARCH(AA57,$F$2:$F$3528)))),""),1)=H57))