That is impressive.
Is it reading the grid from the image description?
If I knew how to code in Raku, I would examine the repository to completely understand your implementation.
I do like that it elegantly handles the asterisks, too.
It sounds like the program is designed to be downloaded to one's own computer and run from the command line (Linux required?)
Could it also be set up as a CGI script?
> Is it reading the grid from the image description?
Yes, it's reading the puzzle from the description.
> If I knew how to code in Raku, I would examine the repository to completely understand your implementation.
I added some more comments trying to explain the implementation. Reading a bit about Depth-First search would help understanding the word-search subroutine.
This program consists of 4 parts:
1. Set the puzzle in @puzzle & starting positions in @gray-squares.
2. Loop over the dictionary words & search the grid.
3. word-search subroutine: Searches the grid for given word.
4. neighbors subroutine: Returns the neighbors of given grid.
Also, do you know Perl? I could probably port it to Perl someday.
> I do like that it elegantly handles the asterisks, too.
Yeah, octans is specific to your word-search puzzles. It only starts at grids with an asterisks.
> It sounds like the program is designed to be downloaded to one's own computer and run from the command line (Linux required?)
It's a Raku script, you would need the Raku interpreter. Rakudo star bundle includes the interpreter along with zef (modules installer): https://rakudo.org/star
Octans requires the WWW module, it's not bundled with Rakudo star distribution so you would have to install it yourself with zef. It's as simple as running: zef install WWW
I just created a branch `without-www'. It's the same code but it'll work without WWW dependency: https://github.com/andinus/octans/tree/without-www
So, if you're able to get the Raku interpreter then you could try running `without-www' branch script. And if you're able to get zef running then simply install the module `WWW' and run the main script.
No, Linux is not required. It should work fine on macOS, Windows & BSDs. In fact I'm running it on OpenBSD.
> Could it also be set up as a CGI script?
Yeah, I could set it up as a CGI script.
I also post the week's images on my own web site.
It might be a "cool" option for people to launch a CGI script as a "solver" even though they can simply hover/click the answer button to get the answer.
I would like to, with your permission, add a link to your program. It is such an honor to me to have you go to all the work of developing the tool.
@Algot Indeed it will be cool. What kind of solver are you thinking of? I think something that visualizes the problem solving will be cool. I'll try making something that does this... someday!
The three variables at the top are:
- @words: This is the dictionary.
- @puzzle: This is the puzzle, note that it's a two-dimensional array.
- @gray-squares: These are positions of starting points for the puzzle.
I'm glad you liked it :) Yes, feel free to link it on your website.
I want to solve this another way. Currently it's going over words in a dictionary and trying to find it in the grid. I'll try starting from the grid & checking to see if that word exist in the dictionary.
The idea is to check if there exists any word in the dictionary that starts with whatever we've build with the grid. If there are none then we try another path. We do this until we find a word in the grid that exist in the dictionary.
This method will be bad for real word-search puzzles but it might be fine for your puzzles because the starting points are restricted in them. I'm actually not sure if it'll be bad but I think so because we're going to load the whole dictionary in memory for this & then we will be performing lots of searching.
I already have some ideas to make that searching part better, we could pass the resulting array when we move ahead because any movement will give us a subset of word that the previous search had.
For example, "hello" will match a subset of matches of "hell" in dictionary. So, we don't have to search "hello" in whole dictionary, we just search it in the results of "hell" search.
This other way I described, my brain tries to solve it this way. It just follows the grid until it finds the word.
Hah, sorry for this wall of text. I'll implement Octans this way sometime in future & also the cgi thing.
And sorry for the delete & re-draft. I organized it properly, this is the final version of this toot!
I tried it with another one:
a l l i
p e c n
e p t e
r s i v
gray (0, 0), (1, 0)
which should get "perspective" which is in my Linux box's words file. Maybe the online words file is different.
@Algot Actually I had modified it to use @words array as the dictionary, I thought there won't be a dictionary file on that machine. But turns out I was wrong, there is a dictionary file.
In this case there are only 3 words in @words: hello, world, terminated & none are present in the grid so it failed.
It does find "perspective" when I use the dictionary.
masto instance for the tildeverse