Skip to content

Instantly share code, notes, and snippets.

@xpqz
Last active February 8, 2022 12:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xpqz/0b594ded5dcaaa84bfdea0cd0ff6454c to your computer and use it in GitHub Desktop.
Save xpqz/0b594ded5dcaaa84bfdea0cd0ff6454c to your computer and use it in GitHub Desktop.
Wordle helper in Dyalog APL
⍝ Function to say if a given word contains every letter in a set
wordle←∧/∊
⍝ Load dictionary, find 5-letter words, downcase
flw←⎕C words/⍨5=≢¨words←⊃⎕NGET'/usr/share/dict/words'1
⍝ All 5-letter words containing the letters 'reld'
↑flw/⍨'reld'∘wordle¨flw
alder
daler
duler
elder
idler
lader
lored
older
redly
urled
⍝ A more complete wordle operator
wordle2←{ ⍝ ⍺⍺ -- excluded letters ⍵⍵ -- green letters in the form '.ra.e'
green←⍵⍵≠'.'
0=(green/⍵)∧.=green/⍵⍵:0 ⍝ check if all greens match in the correct position
~⍺⍺(∨/∊)⍵ ⍝ discard on the excluded set
}
↑flw/⍨('gzotbpulischynd' wordle2'.ra.e')¨flw
arake
frame
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment