There are two values
for a word candidate

1) How likely the word hits Jackpot

2) How much the space is reduced

so a word score
is a weighted sum
presumably 2nd is higher
at least initially

a good dictionary
(and a good data structure)
would be a valuable service
.... maybe for JSoftware.com?

a good DS is somewhat
problematic, in J.
Though a Dictionary
is an excellent example
of a Ragged-Array

ideally it would be
viewable a plain text
consume only a few bytes / word
allow "properties" for each word

problem solutions?

i am working on the
word list

http://storage.googleapis.com/books/ngrams/books/20200217/eng/eng-1-ngrams_exports.html

so far no luck
it is 43GB
and broken into 24 parts

so far my ed
fails at
1) regex'ing relevant parts
2) splicing
... presumably it lacks space

Also the game has two stages
ala alpha-beta pruning
in Wordle beta is trivial
but in Absurdle...

anyway recursive structures
(or Jackknifing/exhaustive search)
need to go to
that bitter end, too

especially with a
non-trivial adversary

~greg heil
picsrp.github.io
i.tgu.ca/real_cal

--

from: Ian Clark <earthspo...@gmail.com>
to: Programming forum <programm...@jsoftware.com>
date: Feb 17, 2022, 2:21 AM
subject: Re: [Jprogramming] wordle comparison

>> To play the game right, it isn't sufficient to calculate the entropy of the 
>> possible calls.  You have to recur to the bitter end…

3Blue1Brown makes that point in his 2nd video.

--

from: Henry Rich <henryhr...@gmail.com>
to: programm...@jsoftware.com
date: Feb 16, 2022, 8:10 PM
subject: Re: [Jprogramming] wordle comparison

>I'm pretty sure I have a complete solution to Wordle.  Some years ago I wrote 
>a program to play Jotto, which has a scoring system that only gives you 1 
>point per letter matched, with no indication of what letter matches.  I 
>modified it for Wordle scoring.

>[If I'm so smart, why can't I sell my program for a million bucks?]

My function for scoring Wordle is

wdtouniq =: ([: {&a. a.&i. + 26 * i.~ (] - {) /:@/:)"1 NB. replace
each letter with combination letter/# previous identical letters
NB. Exact matches count 2 and override the result in that position.
Otherwise, if
NB. a letter/ordinal appears anywhere in the other word, it counts as
asimple match
NB. y is the guess, x is the hidden word
wrdcmp=: ((e. + =)/@:wdtouniq)@:(({.a.)&((0 5 +/ I.@(=/)@])}))@:,: ~

>wrdcmp finds identical letters and replaces them with NUL.  Then, it replaces 
>each letter with (repeat#,letter) where repeat# is the number of previous 
>letters equal to the given letter (it encodes these into 1 byte rather than 
>making them 2 values).  Then it looks for matches.

That's just the beginning.

>To play the game right, it isn't sufficient to calculate the entropy of the 
>possible calls.  You have to recur to the bitter end, calculating the expected 
># turns of each active set of words, because you are only allowed to call 
>valid words.

>Before you start, you have to have a dictionary with a probability associated 
>with each word.  You could make them all identical, if you really think the 
>hidden word is just as likely to be 'zloty' as 'crate'; but I weighted the 
>words according to their likelihood in English text, but reducing the weight 
>of the most common words.  Defining the dictionary is what really defines the 
>game to be played.

>With the dictionary and probabilities I have, I can report that the expected 
>number of turns for the best initial calls are

tears  3.40429
slate  3.4155
tales  3.42104
tries  3.4317
stale  3.43402
rates  3.43807
...

Henry Rich

--

from: Ian Clark <earthspo...@gmail.com>
to: Programming forum <programm...@jsoftware.com>
date: Feb 16, 2022, 4:27 PM
subject: Re: [Jprogramming] wordle comparison

>Being my usual helpful wee self, I was about to proffer this worked example by 
>3Blue1Brown on calculating the best first guess:

[1] https://www.youtube.com/watch?v=v68zYyaEmEA

when 3Blue1Brown posted a retraction:

[2] https://www.youtube.com/watch?v=fRed0Xmc2Wg

>He'd used the wrong hashing algorithm (if we may call it that). The video 
>details his error plus the correction, and reruns the entropy calculations.

>AFAICS Raul has taken the necessary first step in bringing some sanity to this 
>topic. A universally-agreed acceptance test for what he calls *wrdcmp*.

>Could some kind benefactor of humanity please expand Raul's list of asserts to 
>reconcile

- the original Wordle source code, e.g. at:
https://www.wordleunlimited.com
- 3Blue1Brown's retraction, [2] above
- https://rosettacode.org/wiki/Wordle_comparison -which links:
- en.wikipedia.org/wiki/Wordle#Gameplay

>WIBNI (wouldn't-it-be-nice-if) the acceptance test could be run against all 
>the submissions to RosettaCode.

>A version of the acceptance test for Mastermind would be nice as well, since 
>there are non-isomorphic variants of that too.

>Importance: medium to high. Both Mastermind and Wordle are excellent paradigms 
>for teaching Information Theory, in a form applicable to IT rather than to 
>Bayesian statistics.

>What do I mean by that? The IT world needs a formulation of entropy that 
>avoids relying on the notion of probability. Moreover, Bayes Rule and 
>treatments using it are vastly simplified when expressed in bits instead of 
>probability ratios.

--

from: Raul Miller <rauldmil...@gmail.com>
to: Programming forum <programm...@jsoftware.com>
date: Feb 16, 2022, 2:23 PM
subject: Re: [Jprogramming] wordle comparison

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.

--

from: 'Pascal Jasmin'
to: "programm...@jsoftware.com" <programm...@jsoftware.com>
date: Feb 16, 2022, 1:57 PM
subject: Re: [Jprogramming] wordle comparison

>My solution for a guessing algorithm where construction of "a" dictionary a 
>result of forming words from splicing 2 variables in the js code,

a =: > ',' cut '"' -.~ wdclippaste ''
>NB. https://www.powerlanguage.co.uk/wordle/main.e65ce0a5.js dictionary 
>section, must slice 2 sections together, excluding []

pD =: 1!:2&2 :(] [ 1!:2&2@:(,&<))
NB. utility printDebug but return y

ia =: 4 : 'x} y'

indiv1s =: (] # =/~@:i.@#)

legend =: \:~ (~. ;"0~ #/.~) ,a

dict =: (] \: 1 (#@~.@] * +/@:+)"1 (|. > {:"1 legend) i."1 ]) a
>NB. order dict by letter frequency * unique letters per word

score =: e.~ + =
>NB. compare candidate to secret word: 0: no match, 1: wrong pos 2:right pos

>NB. score implies 1 means included somewhere + not in that position.
>NB. for each next function score is x arg, remaining dictionary is y with {.y 
>(first word) wnat was used to score

inp =: {.@] , }.@] ([ #~ 0 = {."1@rxmatch"1~(,@:) ) ('.....' ,: {.@]) ia~ 2 = [

expi =: {.@] , }.@] ([ #~ 0 -.@:= {."1@rxmatch"1~(,@:) ) ('.....' ,:
{.@]) ia~ 1 = [

exp =: ] ] F.: expi 1 indiv1s@:= [

inei =: ] ([ #~ +./@e."1~) {.@] #~ 1 = [

ine =: ] ] F.: inei 1 indiv1s@:= [

out =: {.@] , }.@] ([ #~ +./@e."1~(-.@:) ) {.@] #~ 0 = [

NB. out =: ] ] F.: outi 0 indiv1s@:= [

w =: ([ out^:(0 e. [) [ine^:(1 e. [) [ exp^:(1 e. [) inp^:(2 e. [))(}.@:)

wordle =: ((score {.) w ])^:(-.@:-: pD@:{.)^:_

>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.~ + =

>There is reason to hate the spec compared to elegant solution.  Which of 2 
>extra wrong_place letters get scored 1 vs 0?  So huff+puff the spec is wrong 
>is easy attitude to take.  But relenting with examining score in spec is "if 
>candidate contains more copies of a letter than are present in secret, then 
>score application with extra copies of letter replaced with space meets the 
>spec. while avoiding replacing an extra copy with a candidate letter in right 
>position in secret... is one way to do it.  Easier said than done enough that 
>I'll work on this later.

--

from: Hauke Rehr <hauke.r...@uni-jena.de>
to: programm...@jsoftware.com
date: Feb 16, 2022, 1:03 PM
subject: Re: [Jprogramming] wordle comparison

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.

--

from: Hauke Rehr <hauke.r...@uni-jena.de>
to: programm...@jsoftware.com
date: Feb 16, 2022, 12:38 PM
subject: Re: [Jprogramming] wordle comparison

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

--

from: Raul Miller <rauldmil...@gmail.com>
to: Programming forum <programm...@jsoftware.com>
date: Feb 16, 2022, 11:51 AM
subject: [Jprogramming] wordle comparison

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
,
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to