I’m stupid.
Of course, I need a quadratic component as well: e.
And that’s because the problem isn’t linear as I was
mistakenly led to believe but quadritic in nature.
Again, I didn’t take enough time to think about it
before writing.
Sorry for the noise.
Am 16.02.22 um 21:38 schrieb Hauke Rehr:
How about simply
sel =: [ {"0 1 '_' ,.~ ]
wordle =: 4 : 'eq + x e.&(eq&sel) y [ eq=.x=y'
'momma' wordle 'nomad'
0 2 2 0 1
'momma' wordle~ 'nomad'
0 2 2 1 0
looks like it doesn’t do all too much to me
if you find an easy way without building any
auxiliary structures, I’d be interested
but I doubt it’s that easily solvable:
you need to take into account for each letter
not only where but also how often in some way
and "using progressive index of" already requires
n² time (linear in both arguments)
so my approach with essentially
n (building eq) + 2n (eq&sel) + n (e.) = 4n
operations should be faster I think
I don’t know why one would want to throw concepts
like a connected graphs at an instance with n=5
of a linear problem
and it does have an easily understood linear solution
Am 16.02.22 um 20:51 schrieb Raul Miller:
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,
--
----------------------
mail written using NEO
neo-layout.org
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm