Hello, I got this program I want to write. I know that you will not solve the problem for me, but, I don't even know where to start. So, If you could guide me even to the starting point I guess this will do it.
Imagine a square field, 5X5 cells. every field can contain a letter. (example 1)
example 1
Every time a letter added I need to build an algorithm that will find
any sequence of characters that has at least one free cell near the end of that sequence. (example 2)
Example 2
On example 2 these are only part of the possibilities, and I need ALL of them. I guess this algorithm is something recursive but my knowledge on this topic is very limited. I can't even understand the logic of how it should be done.
So far, I have the cells and a two dimensional array of textboxes:
Code:
TextBox[,] chars = new TextBox[5, 5];
for (int i = 0; i < 5; i++)
{
for (int j = 0; j < 5; j++)
{
chars[i, j] = new TextBox()
{
Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(177))),
Location = new System.Drawing.Point(150 + (31 * j), 12 + (31 * i)),
MaxLength = 1,
Name = string.Format("txtbox{0}{1}",j,i),
Size = new System.Drawing.Size(29, 29),
TabIndex = 0,
Text = "",
Parent = this,
TextAlign = System.Windows.Forms.HorizontalAlignment.Center,
};
}
}
I also thought to drop all the letters into one list of chars and then combine all the possible sequences for 2letters, 3letters, etc... and then check them if they meet the criteria of a free cell at the end, but, I guess this will be very time consuming.
So any idea will be helpful!
Thanks in advance!
-Dimkin