On Wed, Feb 16, 2022 at 4:57 PM 'Pascal Jasmin' via Programming
<programm...@jsoftware.com> wrote:
> the score funtion is what you are looking for.  is super elegant, but does 
> not meet the spec of scoring 0 instead of 1 when there are extra copies of a 
> candidate letter above and beyond the count in the secret.  The elegance.
>
> score =: e.~ + =

It's viable to solve wordle using just counts of exact and inexact
matches (without knowing their positions nor the letters). The
approach is to start with a dictionary of possibilities and exclude
everything shown to be impossible.

Being able to select exact and inexact letter matches, like your
approach here, is also viable. That same approach works, though the
details of which dictionary words match or do not match is a bit
different.

Having the right dictionary is probably the most important facet of
implementing a wordle solver.

That said, I guess should include my current best effort:

wrdcmp=: {{
  yw=. ;(] , ({.~1<.#)@-.)&.>/(<@I.y=/~x#~y~:x),<I.x=y
  2 (I.x=y)} 1 yw} (#y)#0
}}

assert 1 1 2 0 0-: 'allow' wrdcmp 'lolly'
assert 0 0 2 2 2-: 'bully' wrdcmp 'lolly'
assert 0 0 0 1 0-: 'robin' wrdcmp 'alert'
assert 0 2 1 2 0-: 'robin' wrdcmp 'sonic'
assert 2 2 2 2 2-: 'robin' wrdcmp 'robin'
assert 0 0 2 1 0-: 'mamma' wrdcmp 'nomad'
assert 0 1 2 0 0-: 'nomad' wrdcmp 'mamma'

This is a bit more elaborate than your 'score' but it's not too bad.

Thanks,

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

Reply via email to