# Letter Boxed, part 2: this time, solve it

This challenge is a sequel to Letter Boxed Validator.

The New York Times has a daily online game called Letter Boxed (the link is behind a paywall; the game is also described here), presented on a square as follows:

You are given 4 groups of 3 letters (each group corresponds to one side on the picture); no letter appears twice. The aim of the game is to find words made of those 12 letters (and those letters only) such that:

• Each word is at least 3 letters long;
• Consecutive letters cannot be from the same side;
• The last letter of a word becomes the first letter of the next word;
• All letters are used at least once (letters can be reused).

In this challenge, you are given the letters, and a dictionary. The goal is to output a valid solution, which minimizes the number of words used. If there is no solution, any consistent output is acceptable.

For the input {{I,C,O}, {M,R,E}, {G,N,S}, {A,P,L}}, a valid solution is PILGRIMAGE, ENCLOSE. Another valid solution is SOMNOLENCE, EPIGRAM. The following are not valid:

• PILGRIMAGE, ECONOMIES (can't have CO since they are on the same side)
• GRIMACES, SOPRANO (L has not been used)
• PILGRIMAGE, ENCLOSURE (U is not one of the 12 letters)
• ENCLOSE, PILGRIMAGE (last letter of 1st word is not first letter of 2nd word)
• CROPS, SAIL, LEAN, NOPE, ENIGMA (number of words is not minimal)

## Input

Input consists of a dictionary, and of 4 groups of 3 letters. It can be in any suitable format.

## Output

A list of words giving a solution to the challenge. There may be several acceptable solutions: you should output at least one, but may output several if you want.

## Test cases

The test cases use this dictionary. If using a large dictionary is too difficult on TIO, you may use instead the dictionary {PILGRIMAGE, ENCLOSE, SOMNOLENCE, EPIGRAM, ECONOMIES, GRIMACES, SOPRANO, ENCLOSURE, CROPS, SAIL, LEAN, NOPE, ENIGMA, OVERFLOWS, STACK, QUESTIONABLY, QUARTZ, ZIGZAG, GHERKIN, CODE, GOLF, NO, I, DO, NOT, IN}, but your code should in principle work on a larger dictionary.

Note that the solution is not necessarily unique; these are possible solutions.

Input={{I,C,O}, {M,R,E}, {G,N,S}, {A,P,L}}. Solution: PILGRIMAGE, ENCLOSE

Input:{{OSA}, {FVK}, {WEL}, {CTR}}. Solution: OVERFLOWS, STACK.

Input: {{BCD}, {FGH}, {JKL}, {MNP}}. No solution.

Input: {{AQT}, {LUI}, {BOE}, {NSY}}. Solution: QUESTIONABLY

Input: {{QGN}, {ZUR}, {AHK}, {ITE}}. Solution: QUARTZ, ZIGZAG, GHERKIN.

## Scoring:

This , lowest score in bytes wins!

• Sandbox link – Robin Ryder Jun 23 '19 at 11:02
• Do I receive the dictionary as input? – Gymhgy Jun 23 '19 at 11:07
• @EmbodimentofIgnorance Yes, dictionary is part of the input. Clarified. – Robin Ryder Jun 23 '19 at 11:09
• Such a large dictionary is going to be hard to embed in TIO links -- if it's possible at all. I'd recommend to provide a much smaller dictionary including all words used in the solutions and just a couple of other useless ones. – Arnauld Jun 23 '19 at 11:25
• @Arnauld OK, I've added a small dictionary which should be enough for all test cases. – Robin Ryder Jun 23 '19 at 11:35

iⱮⱮL>2ƊƇẠƇ’:3IẠƲƇŒPU=ḢɗƝẠ\$ƇFQL=ʋƇ12ịḷḢ