'gesse' wordle dictThis seems to work with every word I tried:
a =: > ',' cut '"' -.~ wdclippaste '' NB. https://www.powerlanguage.co.uk/wordle/main.e65ce0a5.js dictionary section, must slice 2 sections together, excluding [] NB. instead of wdclippaste '', can include the javascript quoted comma separated array enclosed in '' 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 = [ w =: ([ out^:(0 e. [) [ine^:(1 e. [) [ exp^:(1 e. [) inp^:(2 e. [))(}.@:) wordle =: ((score {.) w ])^:(-.@:-: pD@:{.)^:_ 'gesse' wordle dict NB. x is secret word. printout includes each successive guess. End result is remaining dictionary as a result of next to last guess. arose dulse nisse cesse gesse gesse fesse jesse 'guess' wordle dict NB. if secret is only solution after next to last guess then "double secret" ends the printout. arose neist plesh guess guess 'gudss' wordle dict NB. if secret is not in dictionary, then dictionary will eventually empty. arose tulsi dunsh pudsy an interesting solution to applying a function that is designed to be "for all true elements/positions" into a "for every true position" is the "adverb structure/boiler plate" between the core i-suffix functtions and the final functions using F.: and itemizing any true positions into a list of one at a time that matches the need of the "core" (i-suffix) function. Another example of adverbs solving a corner case or "bug", in w, the ^:(n e. [) serve to guard against error conditions that happen to also mean that the guarded functions would not need to run. On Monday, January 24, 2022, 01:39:50 p.m. EST, Raul Miller <[email protected]> wrote: The absurdle approach is essentially what I was doing with my 'possible' variable in http://jsoftware.com/pipermail/programming/2022-January/059738.html I should perhaps also note that a 'bestGuess' implementation is not viable unless the word list is constrained to only words accepted by the wordle game implementation: bestGuess=:{{ abc=. /:~~.,y weights=.+/(abc i.|:y) {"1 #/."1~abc,"1|:y sel=. (= >./)weights y{~ (0,+/\sel#weights) I. ?+/sel#weights }} The problem here is that 'best' may exclude all words accepted by the game. But this would be decent if we were working with fives=: >LF cut gethttp {{)n https://gist.githubusercontent.com/cfreshman/a03ef2cba789d8cf00c08f767e0fad7b/raw/27a096e8eecf3edc39098fea0f70f2c61abf2393/wordle-answers-alphabetical.txt }}-.LF (For what it's worth: I looked at that slate.com strategies page, but I couldn't think of any way to upgrade the algorithms I have implemented in this thread based on that description.) FYI, -- Raul On Mon, Jan 24, 2022 at 12:04 PM greg heil <[email protected]> wrote: > > you might appreciate > https://qntm.org/wordle > which takes partitioning > of words to > demonic heights > see > https://www.theguardian.com/us-news/2022/jan/13/absurdle-machiavellian-version-of-wordle > > this has been overdone > on social media > but a good entree for strategies is > https://slate.com/technology/2022/01/wordle-how-to-win-strategy-crossword-experts.html > > > ~greg heil > picsrp.github.io > i.tgu.ca/real_cal > > -- > > from: Raul Miller <[email protected]> > to: Programming forum <[email protected]> > date: Jan 24, 2022, 8:39 AM > subject: Re: [Jprogramming] wordle > > >I should add: > > >(1) If you do not have a /usr/share/dict/words, you can google for that and > >find plenty of examples. > > >(2) There's also a wordle specific words list -- you can just pull it out of > >the javascript for the page, like greg heil mentioned (and since those are > >in sequential order, solving one wordle would give you the next day's wordle > >solution also -- but where's the fun in that?). Or, you could use something > >like > > https://gist.github.com/cfreshman/a03ef2cba789d8cf00c08f767e0fad7b > > >(3) I could have done a better job of picking a next guess. But I haven't > >thought through enough about the entropy associated with the possibilities. > >Conceptually, each guess creates a partition on the possible answers and we > >probably want to minimize the size of the largest element of that partition. > > The largest partition is probably going to be the partition with the > >maximum number of grey letters (or maybe with one yellow letter). But just > >guessing arbitrarily seems to work. > > >That said, this might be a better guesser: > > goodGuess=: {{ > abc=. /:~~.,y > weights=.+/(abc i.|:y) {"1 #/."1~abc,"1|:y > y{~ (0,+/\weights) I. ?+/weights > }} > > Basically, goodGuess would replace ({~ ?@#) and it tends to favor > words with commonly occurring letters. > > Thanks, > Raul > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
