Scrabble puzzle discussion

I don’t know what is in the validator (only CG does, and they ain’t telling) so I can’t say for sure what the problem is. However, your code has a couple of problems.

Try these 2 test cases:

(should be flea)

(should be cow)

Hopefully that’ll help you find the problem. Let me know if you need more assistance.

1 Like

I was also stuck on this for ages, scratching my head wondering why all the tests passed, except the “Valid word” submission test. It was only by searching and finding this forum post, that I discovered that one of the input tests could be using less than 7 letters. I agree that the puzzle description ought to be updated to mention that the last line might not give you a full 7 letters!

In terms of scoring a word, I wrote this (in Python), which IMHO looks quite neat :slight_smile:

[no full solution here please]

On the last test the Large dictionary 2 I keep running in to the problem of equivalent words.
The letters chosen are “retpasn”
The words that work are:
napster 9
pastern 9

The answer only recognizes “pastern” even though the 2 words are the same score. Not sure how to get the answer the validator would like. All the other tests pass without issue.

If you use a stable_sort then the correct answer is given. I believe this is an error since it relies on the order of the words in the dictionary. This should be a stipulation in the question if that is what is intended.

From the problem description:
A dictionary of authorized words is provided as input for the program. The program must find the word in the dictionary which wins the most points for the seven given letters (a letter can only be used once). If two words win the same number of points, then the word which appears first in the order of the given dictionary should be chosen.

1 Like

Ahh thanks I did not see that!

My code works fine and passes every test, however, I am quite certain that one possible test case would fail:

Take ‘arrest’ for example: My code is most certainly not capable at the moment to ensure that two ‘r’ are available in the given letters to form words with. It is capable of running every test case, though, which is due to the fact, that I check the word length and given letter’s length. This makes it possible to circumvent a check for multiple letters without actually being able to form it.

However, as from what I have seen so far, this case has not been testing in any of the available test?
Or am I missing something?

THANK YOU so much. You were right. I had spent few hours before saw your comment.


j’ai réussi l’exercice mais lorsque je soumets mon résultat, l’IDE me refuse l’exercice 4 et 7.

pouvez-vous me conseiller?


I pass all the test in the editor, but I don’t pass the last blind test, and I have no way to know why. I’m in c++, does anyone have a solution or a way to understand why ? (I’m in c++).

I already check if the dictionary word has less or egal number of letter than the player get.

Is that could be the time of the execution ? (but I pass all the other large dico)

Are you sure of that ?
i mean how could you tell?

Checking others’ solutions I noticed that many took the approach of going through the dictionary to get the first highest valued word that could be wirtten with the given letters.

While this is fine for the CodinGame practice, I took another approach thinkinga about the real scrabble game. In that case, the dictionary would have been fixed once for all and the cost of seting it up doesn’t matter (as it can be done once for all before any game). The problem, then, would be to check as fast as possible all the possible word against the dictionary.
This means spending only log(N) to search into the dictionary rather than N.
I solved it using this approach and I wonder if anyone did the same or rejected it for some reason.

I only checked some of the C solutions as I only did it in C.

(Of course I do not go through all the 1 * 7! +7 * 6! +21 * 5! + 35 * 4! + 35 * 3! + 21 * 2! + 7 words! :slight_smile: )

Why not? It’s only 13699 words.

Because you could do it with just 127 words :slight_smile:.
It could have been even less ( considering a letter may occur multiple times) but I deemed the saving was not worthy the extra work.

I thought that you had found that it’s a too large value. :wink:


I don’t understand why my algo is wrong for Valid Word test case.
I get following scores for these words:
Words [‘qzyoq’, ‘azejuy’, ‘kqjsdh’, ‘aeiou’, ‘qsjkdh’]
Scores [21, 13, 10, 5, 10]

So the winner is obviously ‘qzyoq’ (q 10+ z 10+ o 1) but the test case replies it’s ‘aeiou’.
Any hints ?

Best regards,

There is only one ‘q’ and no ‘y’ among those given for the “Valid Word” test case. So, even if its value would be higher, you can’t form the word ‘qzyoq’.

1 Like

Thank you very much.
This is the point I missed: you have to ensure all characters in present in the word and not only comparing word scores.

what wrong with this tests?

ide test 06 “Valid word”
letters: qzaeiou
found: qzyoq (weight 21)
expected: aeiou (weight 6)

ide test 07 “Large dictionary 1”
letters: aretsui
found: universality (weight 7, used 100% of letters)
expected: satire (weight 6)

If you only have 1 ‘q’ and no ‘y’, how can you write ‘qzyoq’ with that?
In test 7 you miss several letters as ‘n’, ‘v’, ‘l’ and ‘y’ to write the word you propose.

1 Like