Scrabble puzzle discussion

Does any previous reply help you, e.g. reply to this previous message? https://forum.codingame.com/t/scrabble-puzzle-discussion/46/8

to anyone else who feels like their algorithm is perfect but keeps failing a validator, double check your hash map because i spent too long debugging to realize i didn’t put x in mine, which none of the IDE tests picked up.

1 Like

on C# 2 of the test cases are failing as the test case values they expect is incorrect

Test case 2 states it is expected “potsie” it should be expecting “postie”
Test case 8 states it is expecting “pastern” it should be expecting “napster”

The statement says:

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.

damn thanks for pointing that out constantly miss reading bits :confused:

Same issue here, may I also have the validator test ?

Thanks a lot !

Hi, I can’t pass the validation of the “Valid Word”.
I just don"t get how i can see if a word is correct or not, i already check if a word has no voyel in it, but don’t understand what else i can do, any ideas ?

The requirement is to check what words you can make with the given letters. Whether a word has any vowel in it is irrelevant.
Please search “Valid word” in this post for the previous discussion on this validator.

Tanks for your answer, I thought I had to check if a word is correct as the test is named “Valid Word” and i had an error only on this one, but in fact i just had a typing error in a if statement that the tests were not triggering :^)

because hicquwh has two “h” available

image

image

image

but I take the first if same points here (store if only superior)
image

Hi, I have been coding in python and everything in the code looks fine but I keep failing on the many possibilities test. I have passed all other tests but this one continuously fails me. Anyone know why this is happening?

Updated Response: Okay I changed something and now I am passing all tests but failing the 4th test on submission. Anyone know why this is happening?

Updated Response 2: I did some debugging and figured out that the 4th test fails because of the order of the code. Anyways I have 100% now.

Why does the 2nd example have to be: “potsie”:8, instead of “back”:12?

None of the characters of “back” is available (see the last line of the inputs for available characters).

Excellent coding exercise to work through, thanks!

Hello,
Strange thing, in IDE I am passing all tests but when submitting first test case ‘Only one word’ is failing.
When I get input I calculate how many times I can use specific letter, so in first scenario I get:
available_letters = {‘h’: 2, ‘i’: 1, ‘c’: 1, ‘q’: 1, ‘u’: 1, ‘w’: 1}
so ‘h’ can be used twice and so on…

How my algorithm works for each word in dictionary I:

  • check if length is not greater then 7 (number of letters we draw), if it is longer then word is incorrect
  • for each letter in word I check in available_letters if letter is in dictionary and secondly if count is larger then 0 if those requirements are met then word is still correct, I add points and decrease count in available_letters
  • when I finish iterating over letters then I check word score and size. If score is higher then previous one, then this is new best word. If the score is the same as current best then I compare sizes of words. If size of word is smaller then size of current best then current word is new best

Is there anything hidden I forgot? I use python3

Please note that validators are different from tests, so it’s entirely possible that you pass all the tests and still fail one or more of the validators.

I’m confused by “for each letter in word I check in available_letters if letter is in dictionary”. I think you mean “for each letter in word I check if letter is in available_letters”?

According to the statement,

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.

which does not seem to be what you’re doing as per your description.

Fixing the above may not necessarily help you pass the first validator. I would suggest you to go over the statement and your code again and check for any discrepancies.

Shame to confess… It turned out I did typo in defining points per letter. I had in my dictionary {" l": 1} (extra whitespace before letter) and validator must have thrown KeyError since letter ‘l’ was not found.

1 Like