spot;1513199 wrote: Indeed it is:
$ time sld grid-r
grid-r has 10 clues in 6 columns by 4 rows
initial grid
. . . . . .
c . . . . .
. . . . j .
. . q . . .
final grid - solved
o c c u r s
c r i n a l
t i n a j a
a s q u a t
real 0m1.700s
I came to a grinding halt on setting puzzles though. I can't do it yet and you can, which bothers me.
If, for example, I add one of the letters from A..Z into any blank cell of a blank grid, it takes me 26*cells to test all the alternatives. I can do that but I'm not expecting to find any more unique solutions with just one letter, not at the moment. That exploration takes about 10 minutes with my process in a 6x4 grid.
If I allow two letter permutations, it would take me of the order of 4 hours with 26*(cells)(cells-1) iterations.
Three letters is around 4 days. And so on. And that's just for a single grid-shape, 6x4, and there is a huge range of grid shapes to explore for unique solutions.
Is there a shortcut I'm just not seeing? or can I not exhaustively explore the full set of unique solutions.
Here's the simplest I can come up with:
Hello Spot. Congratulations on solving the puzzle.
As you surmised, the problem of making this kind of puzzle is complicated. And yes, it making or solving puzzles is theoretically exponential in nature IF (and that is a big IF) you don't use certain shortcuts. I have been working on this for the past 35 years. Yes, you read this correctly, 35 years.
My first program was on a Commodore 64 and the code was written in Forth64, an implementation of Forth for the Commodore 64. Then I moved to a Commodore Amiga 2000. There, I rewrote my code in JForth, a version of forth that allowed you to use the assembly language of the Motorola 6800 processor in the Amiga. Much better. Finally, I then reluctantly moved to the PC in the early 90's and rewrote everything in C++.
However, I was not writing what I have today, but instead I was writting code to try and win a prize from a company called American Holiday Association. They had word puzzle contests where you could win money or cars (Porsches and other nice ones) if you could solve them (you can read about it at
https://en.wikipedia.org/wiki/Puzzle_contest).
They made tons of money with people entering all the different stages of the different contests (and paying $5 to enter). I never won and I learned why in the late 80's. At the time, I was a graduate student studying for his Ph.D. in Electrical Engineering at City College Of New York. I was also working at Mount Sinai Hospital on my doctoral research and was a intern at IBM's T.J. Watson's Research Laboratory in Yorktown Heights. I mentioned my efforts one day to a member of my group who was a full time researcher and he laughed saying how he and another employee had entered the contest and one $7000. The rules of the contest were that you could not use a computer, but I knew now why I was always coming up with scores that were 98% or so of the winning score. I am pretty sure many others were also using computers in the contests.
Well, after that major discovery, I knew I would probably never match IBM's computers with their memory and speed. By the way, the list of words for that contest were all the words that were in bold face and against either of the 2 margins in the Merriam-Webster little red dictionary. As you can imagine, there were 1000's of words there. How did I get them in my commodore 64? The old fashion way. I typed them all into my Commodore 64 and saved the file to a diskette! Yes, I was typing all those words, for a couple of weeks while sitting in front of the TV. And, yes, there were some typos which I would discover in a solution of a puzzle. I would then edit the file and rerun the program.
Anyway, at that time I decided that what I had could be the basis for a crossword puzzle making program. My program could take a crossword grid and, based on a dictionary (my list of words for the contest, but it could be any language), fill the puzzle. One would now have to come up with the clues, but I figured that one could come up with some database of clues. Spending my days at Mount Sinai Hospital, I was close to where the major newspapers were in Manhattan. I called a number of them to see if they would be interested in a program that could make crossword puzzles. They all said that they prefer making them by hand (remember, this is in the mid to late 80's). I did not let that answer discourage me. I just kept on working on my algorithm as I enjoyed the challenge of trying to make it better, faster and more efficient.
Well a few years went by. Sometimes, I wouldn't touch the algorithm for a year at a time (as when I moved to FLorida and had to concentrate on my new job). But every so often I would go back to it, such as when I would get a new computer and needed to make sure that my program, which now had nice graphics, would work.
Then I got a teaching position in the Department of Computer Science at the University Of South Florida. Based on my industry experience, I saw that the Department needed to have a course teaching C++. I created that course and it is now part of the curriculum. This made me spend more time on the application. Then the following year, seeing that there was no course in C# in the department, I created an object-oriented programming Course in C#. That course is also, now, part of the curriculum. As I was teaching the C# course, I wanted to give myself a project that would use C#. The project I gave myself was to translate my C++ puzzle making program to C#. Though there were tens of 1000's of lines, this would take about 3 days because of the syntactic similarities between the 2 languages. I ended up with a nice C# library and a prototype for my C# application and also realized that I had the makings of an interesting game based on my application.
So, I went ahead and built prototypes of games based on my library. I even got the help of a bright student who helped make a Unity version of an application based on the library. The fruit. so far of that is a game called "Typing Tiles" which is available for free for Android and IOS. You can get it at
https://itunes.apple.com/us/app/typi...255271144?mt=8 for IOS or at
https://play.google.com/store/apps/d...ingTiles&hl=en for Android. I mention this to you because I believe that if you get the app, you will get an inkling of how the algorithm works.
My algorithm is pretty fast and solved your puzzle in the blink of an eye and came up with:
It can generate a 6x4 puzzle in a split second and a number of them at the rate of perhaps 10 per second. The puzzles can have any rectangular shape.
As for the game that I mentioned to you, the goal is simple. The application will present you with a number of grids. The goal is for you to fill the grid by placing letters in the different squares. My algorithm makes sure that a letter insertion is accepted only if there is still a solution to the puzzle at that point. The unique thing about the app is the "FORCING" rule. That rule stipulates that whenever you place a letter and other letters have only 1 choice, those letters are placed in the grid for you. So, for instance, looking at your puzzle effort above, my algorithm saw right away that given the "X" in the upper left corner the only top horizontal words would be "XRAY" or "XYST", the first column can only be "XI" or "XU" and quickly working through constraints it found the solution I posted below.
As you fill the grid, you get points for the letters you put in (the same values as the letter values used in Scrabble). You are also given a limit to the number of insertions you can make. That limit is the number of empty squares in the grid. So, if the puzzle has 20 empty squares. you are given 20 insertions, at most, to fill the grid. If you are able to force many moves, you could fill the grid and be left with extra moves. Those extra moves give you bonus points. Also, as you FORCE words, their definitions appear in a marquee at the top of the screen. In this way, should you FORCE and unknown word, you can learn its meaning. Finally, the app keeps track of the words you use and gives extra points when you use new words that you have not used in the past. As you solve grids, more difficult ones are presented to you.
It is a great way to learn new words and, in particular, to learn esoteric spelling quirks of words. You quickly learn things like "What is the only 4-letter word with a 'Q' as its 2nd letter?" (AQUA), or "What is the only 5-letter word starting with 'AO'?" (AORTA) or "What letter comes after 'Q' in every 5-letter word where the Q is the 2nd letter?" ('U'), etc...
I am working on making the game available in other languages (Spanish, French, etc...) and on versions that use the words from a particular book as lexicon (Moby Dick, Alice in Wonderland, King James Bible, etc...)
You might also want to read a good article about puzzle making algorithms at
https://www.cs.rpi.edu/~dhulena/CS44Fin ... Report.pdf
Well, this response has turned out a little longer than I anticipated, but you seem genuinely interested in what I have done and you have also seen how complicated this can be.
Feel free to ask specific questions and I will see if I can offer answers,
Regards,
Henrick
Attached files