Last active
February 8, 2022 12:55
-
-
Save xpqz/0b594ded5dcaaa84bfdea0cd0ff6454c to your computer and use it in GitHub Desktop.
Wordle helper in Dyalog APL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
⍝ 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