Filtering question

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

SWEdeAndy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 257
Joined: Sat Aug 16, 2008 9:48 am
Location: Stockholm, Sweden
Contact:

Re: Filtering question

Post by SWEdeAndy » Thu Jan 20, 2022 8:54 am

bn wrote:
Wed Jan 19, 2022 8:52 pm
Thank you very much again for this beautiful piece of code.
I join in the praising - that was an awesome solution, Dick!
I'll remember that method for future cases.

I think a Wordle solver would be a great case study as a LiveCode project.
The above is already a start, and then increasingly complex "singling out" algorithms can be implemented, based on correct or semi-correct letters etc.
Andreas Bergendal
Independent app and system developer
WhenInSpace: https://wheninspace.se

rkriesel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 118
Joined: Thu Apr 13, 2006 6:25 pm

Re: Filtering question

Post by rkriesel » Fri Jan 21, 2022 7:41 am

SWEdeAndy wrote:
Thu Jan 20, 2022 8:54 am
I join in the praising - that was an awesome solution, Dick!
I'll remember that method for future cases.

I think a Wordle solver would be a great case study as a LiveCode project.
The above is already a start, and then increasingly complex "singling out" algorithms can be implemented, based on correct or semi-correct letters etc.
Thanks, SWEdeAndy. Since I'm honored by the praise, I must be sure to thank LC for the filter command, and for the dictionary entry that made this solution possible.
Can you specify the Wordle algorithms?

Jellicle
Posts: 453
Joined: Thu Feb 24, 2011 11:07 am

Re: Filtering question

Post by Jellicle » Fri Jan 21, 2022 7:57 am

rkriesel wrote:
Wed Jan 19, 2022 8:07 am
Hi, Jellicle. Here's a technique that runs over twenty times as fast as the nested-repeat technique (as coded by SWEdeAndy):

Code: Select all

function filterWordsWithChars pWords, pChars
   repeat for each char tChar in pChars
      filter pWords with "*" & tChar & "*"
   end repeat
   return pWords
end filterWordsWithChars
This is fantastic! Many thanks!

g
14" MacBook Pro
Former LiveCode developer.
Now recovering.

bobcole
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 133
Joined: Tue Feb 23, 2010 10:53 pm
Location: Saint Louis, Missouri USA

Re: Filtering question

Post by bobcole » Fri Jan 21, 2022 6:48 pm

Here is a stack that uses two filtering techniques on lists of Wordle words.

To scan Wordle's Guess Words these techniques use LC's built-in features (see the Dictionary):
The first technique uses LC's matchText function; and
The second technique uses LC's filter command.

FYI:
The word lists come from this web article (see the Riddler Classic section):
https://fivethirtyeight.com/features/wh ... et-wordle/
Wordle's 12,972 "Guess" words are acceptable to enter as an attempted solution; and
Wordle's 2,315 Magic words are the only possible answers.

Please feel free to adapt or use this stack in any manner. I claim no credit for this stack.
Enjoy,
Bob

Wordle Tools.livecode.zip
(49.9 KiB) Downloaded 100 times

rkriesel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 118
Joined: Thu Apr 13, 2006 6:25 pm

Re: Filtering question

Post by rkriesel » Sat Jan 22, 2022 3:30 am

Jellicle wrote:
Fri Jan 21, 2022 7:57 am
This is fantastic! Many thanks!
You're welcome, Jellicle. Thanks for the opportunity.
-- Dick

Post Reply

Return to “Talking LiveCode”