Dev Ghai commited on 2013-12-25 06:51:07
Showing 3 changed files, with 23 additions and 29 deletions.
| ... | ... |
@@ -72,6 +72,8 @@ namespace Boggle |
| 72 | 72 |
isError = false; |
| 73 | 73 |
Console.WriteLine("Please enter number of tiles that make up one side of the board: ");
|
| 74 | 74 |
input = Console.ReadLine(); |
| 75 |
+ char[] array = input.ToCharArray(); |
|
| 76 |
+ //input.to |
|
| 75 | 77 |
if (!int.TryParse(input, out boardSideLength)) |
| 76 | 78 |
{
|
| 77 | 79 |
Console.WriteLine("Invalid Input.");
|
| ... | ... |
@@ -127,9 +127,13 @@ namespace Boggle |
| 127 | 127 |
string word, substring; |
| 128 | 128 |
ListWord prevListWord; |
| 129 | 129 |
int startIndex; |
| 130 |
- |
|
| 130 |
+ int maxWordLength = boardSideLength * boardSideLength + 1; |
|
| 131 | 131 |
while ((word = rawList.ReadLine()) != null) |
| 132 | 132 |
{
|
| 133 |
+ //ignore the word if it cannot logically exist on the board. |
|
| 134 |
+ if (word.Length < minWordLength || word.Length > maxWordLength) |
|
| 135 |
+ continue; |
|
| 136 |
+ |
|
| 133 | 137 |
//First deal with the head node and then deal with following letters. |
| 134 | 138 |
startIndex = 0; |
| 135 | 139 |
word = word.ToUpper(); |
| ... | ... |
@@ -187,6 +191,22 @@ namespace Boggle |
| 187 | 191 |
return _WordList; |
| 188 | 192 |
} |
| 189 | 193 |
|
| 194 |
+ private void SaveDictToDisk(Dictionary<string, ListWord> hierarchicalDict, string filename) |
|
| 195 |
+ {
|
|
| 196 |
+ } |
|
| 197 |
+ |
|
| 198 |
+ private Dictionary<string, ListWord> LoadDictFromDisk(string filename) |
|
| 199 |
+ {
|
|
| 200 |
+ } |
|
| 201 |
+ |
|
| 202 |
+ private bool DictExistsOnDisk(string filename) |
|
| 203 |
+ {
|
|
| 204 |
+ } |
|
| 205 |
+ |
|
| 206 |
+ private string DictFilenameOnDisk(int boardSideLength, int minWordLength) |
|
| 207 |
+ {
|
|
| 208 |
+ } |
|
| 209 |
+ |
|
| 190 | 210 |
/// <summary> |
| 191 | 211 |
/// Checks to see if the proper file exists that contains the appropriate words. |
| 192 | 212 |
/// </summary> |
| ... | ... |
@@ -1,28 +0,0 @@ |
| 1 |
-using System.Collections.Generic; |
|
| 2 |
- |
|
| 3 |
-namespace Boggle |
|
| 4 |
-{
|
|
| 5 |
- /// <summary> |
|
| 6 |
- /// Equality comparer used for HashSet. No longer used as I switched to Dictionaries. |
|
| 7 |
- /// </summary> |
|
| 8 |
- public class WordComparer : EqualityComparer<WordOnBoard> |
|
| 9 |
- {
|
|
| 10 |
- public override bool Equals(WordOnBoard x, WordOnBoard y) |
|
| 11 |
- {
|
|
| 12 |
- return string.Compare(x.Word, y.Word, true) == 0; |
|
| 13 |
- } |
|
| 14 |
- |
|
| 15 |
- public override int GetHashCode(WordOnBoard obj) |
|
| 16 |
- {
|
|
| 17 |
- int hash = 0; |
|
| 18 |
- for (int i = 0; i < obj.Word.Length; i++) |
|
| 19 |
- {
|
|
| 20 |
- hash += (int)obj.Word[i] * 10 ^ (obj.Word.Length - 1 - i); |
|
| 21 |
- |
|
| 22 |
- //cat would result in 99 * 10^2 + 97 * 10^1 + 116 * 10^0 = 10986 |
|
| 23 |
- } |
|
| 24 |
- |
|
| 25 |
- return hash; |
|
| 26 |
- } |
|
| 27 |
- } |
|
| 28 |
-} |
|
| 29 | 0 |