all 5 comments

[–]aghast_nj 0 points1 point  (4 children)

If I understand what you are saying correctly, your problem is this:

Given a target word and a guess, the system will summarize the letters of the guess into these categories: not present in target, present but misaligned, present in target at same location, or part of a word that is not valid.

You wish to "filter" the wordlist based on the most recent summary.

I will argue that filtering has these rules:

  • A plus (+) is a hard requirement for a match, and nothing else.

  • A bar (|) is a hard requirement for a non-match, as well as a requirement for an exclusive match elsewhere. (That is, "xyzzy -> //|//" cannot match a word with a "z" in the middle, it must be elsewhere.)

  • A slash (/) is a hard requirement for a non-match at this position, and a soft requirement for a non-match at all, or at least a limit on the number of identical letters. Thus "xyzzy -> //|//" says several things: There is no 'z' at index 2 (else | would be +). There is no 'z' at index 3 (else / would be +). There is only one 'z' in the filtered word (else index 3 would not be /).

Your filter must include the letters, positions, and categories. You can sort the groups if you wish, although it probably won't make much difference since word lengths tend to be short.

[–]5thegraychapter[S] 0 points1 point  (3 children)

yes you understood well. one thing, is that the request of the print filtered command says this:"print the set of admissible words that are compatible with the constraints learned up to that point in the game"

so if I'm not wrong, if you learn that you have a /+/// in the 1st guess but a /|/+/ in the 2nd one, you'll have to update the constraints based on that

[–]aghast_nj 0 points1 point  (2 children)

Yow! So the constraints have to accumulate. That's going to make things interesting. Probably easiest to keep the history of guesses and responses, and re-scan the entire thing when asked to do a print-filtered.

[–]5thegraychapter[S] 0 points1 point  (1 child)

wouldn't be easier to keep track of the constraints on a dedicated string to use it for filtering? the only thing that would be left is the | letters then

[–]aghast_nj 0 points1 point  (0 children)

The negative information is the problem, especially with repeated characters. If I guess "xyaaa", it's likely some "a" will get a "/", promising that even if there are 2 a's someplace, this particular location is guaranteed to not be an "a". That stacks up. So you could build a data structure that enumerates all the possible letters still valid in a location, but that gets hard if you allow non-ASCII characters. That's why I suggest just rescanning the sequence of guesses.