https://rosettacode.org/wiki/Wordle_comparison

Wordle comparison compares a guess word to a reference word and
assigns green / yellow / gray values to each guess letter based on
some rules:

Matches which are in the right position are green.

Letters which do not occur in the reference are gray.

Letters which occur in the reference but not in the same position are
yellow or gray, depending on how many times the letter occurs.

At first glance, this might seem like a job for progressive index of.
But this is complicated by the fact that a later occurrence of an
exact match might deplete the "supply" of that letter.

For example, if the reference word was 'nomad' and the guess word was
'momma', the result should be 0 2 2 0 1 (which index ;:'gray yellow
green'). Similarly, if the reference word was 'momma' and the guess
word was 'nomad', the result should be 0 2 2 1 0.

Anyways, "progressive index of" seems to solve only a part of the problem here.

It seems like there ought to be a concise way of expressing this in J
-- some sort of double reverse progressive index of or a bitmask
shadow system or maybe a connected graph concept. Even nicer would be
if this approach were also space and time efficient. But I have not
figured any of that out yet.

Does anyone else want to take a stab at this?

Thanks,

-- 
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to