I created this application a couple of months ago: http://www.mondofacto.com/word-tools/scrabble-solver.html
The application lets the user enter the set of letters they are given, and echos back what valid words they can use, along with what score they will get for using those letters.
Basically, what I want to do is extend the application so users can enter a 'blank tile' - that being one which can qualify as any of the 26 letters of the alphabet, and to echo back words that are valid.
Below is a screenshot of the database structure.
http://i37.tinypic.com/28v6a8h.png
You might need to copy that ^ into your browser.
The query run on this data when a user enters, for example, 'aardvark' - is as follows:
SELECT * FROM scrabble WHERE a <= 3 AND b <= 0 AND c <= 0 AND d <= 1 AND e <= 0 AND f <= 0 AND g <= 0 AND h <= 0 AND i <= 0 AND j <= 0 AND k <= 1 AND l <= 0 AND m <= 0 AND n <= 0 AND o <= 0 AND p <= 0 AND q <= 0 AND r <= 2 AND s <= 0 AND t <= 0 AND u <= 0 AND v <= 1 AND w <= 0 AND x <= 0 AND y <= 0 AND z <= 0 AND length <= 8 ORDER BY scrabble DESC
If you want to see the results type a word into the link I posted at the top.
Right,
So does anybody have any idea how to approach doing this? I have started with the following code, which appends each alphabet character onto the end of the string entered by the user, if they put spaces in (spaces being the blank tile).
if (preg_match('/[\s]/', $string)) {
$wild_string = $string;
foreach (range('a','z') as $i) {
$wild_string = $string;
$wild_string .= $i;
}
The $wild_string variable is the one which each letter is appended to on loop. By resetting it to the initial string on every loop it stops the code from adding all 26 letters onto the entered string.
I hope somebody can help, and sorry if I have waffled :)
Andy.