Word Selection for Quantum Wordle - Valid Dictionaries and Sampling Procedure

Hello,

the project description states:

If the generateDict function is given a pointer to choose a second word, you have to uniformly at random² choose both words such that they fulfill all restrictions.

with the footnote “clarifying” this as follows:

Chose the second word from the set \{b\mid \text{chars}(b) \cap\text{chars}(a) = \emptyset\}. If the set is empty, chose another a.

For brevity I will refer to the set in the second quote as S(a).

I have three questions:

  1. May we assume that the language L (on the alphabet \Sigma) represented by the input dictionary satisfies the condition \exists a\in L: S(a) \neq \emptyset?
  2. If we may not assume this, does this mean that handling dictionaries/languages without the above condition is undefined behaviour?
  3. Am I right in assuming that we are supposed to pick b uniformly from the sub-dictionary S(a) after picking a uniformly at random from the entire dictionary? A more clumsly way would be to pick b uniformly at random from the whole dictionary (assuming S(a)\neq \emptyset of course) until I get one with b\in S(a). Which is the intended sampling method? (Both lead to different probability distributions)

Thanks for any clarifications!

Hey,

  1. You may not assume that there exist two words with disjoint sets of characters.
  2. Since the project description does not specify the behavior, I would say it is kind of undefined, however it specifies that you should return two words with no common characters. So, if there is no such pair of words, you probably should not return words that share characters.
  3. From my undestanding: "Choose the second word from the set S(a)" means choose the second word uniformly from S(a).

Best,
Tim

1 Like

Thanks for the fast reply! The first and third points make sense, but the second one is too vague for my taste. I don’t want to lose points because something is “kind of undefined” and then the eval tests don’t agree with my way of doing things.

In fact I don’t return words at all, so it seems to me that the best way of proceeding is to set both selected1 and selected2 to NULL if no two such words can be found. This would however require me to check whether the dictionary satisfies the condition from my post above. Then in main I could catch the case:

(selected1 == NULL) && (selected2 == NULL)

by exiting the program.

Of course none of this is in the project description, so I would like a definitive stance on this before I define a bunch of functions that essentially cover undefined behaviour.

Writing a program that diverges if there are no such words is fine. I don’t know about returning NULL. @Marcel.Ullrich can you clarify?

Best,
Tim

1 Like

By definition of the interface generateDict, you are not able to set selected1 or selected2 to NULL. You would need a char** for that.

The case that selected2 != NULL and that the dictionary does not contain two words with a distinct character set is indeed undefined.
By definition of undefined behavior, this case will never occur.

You could for instance diverge or print an error message and exit with EXIT_FAILURE.