Dev Ghai commited on 2013-12-25 06:53:30
Showing 3 changed files, with 29 additions and 23 deletions.
This reverts commit e45d2a57de8341b601c70ba3eeb9761acffed3c2.
| ... | ... |
@@ -72,8 +72,6 @@ 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 |
|
| 77 | 75 |
if (!int.TryParse(input, out boardSideLength)) |
| 78 | 76 |
{
|
| 79 | 77 |
Console.WriteLine("Invalid Input.");
|
| ... | ... |
@@ -127,13 +127,9 @@ namespace Boggle |
| 127 | 127 |
string word, substring; |
| 128 | 128 |
ListWord prevListWord; |
| 129 | 129 |
int startIndex; |
| 130 |
- int maxWordLength = boardSideLength * boardSideLength + 1; |
|
| 130 |
+ |
|
| 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 |
- |
|
| 137 | 133 |
//First deal with the head node and then deal with following letters. |
| 138 | 134 |
startIndex = 0; |
| 139 | 135 |
word = word.ToUpper(); |
| ... | ... |
@@ -191,22 +187,6 @@ namespace Boggle |
| 191 | 187 |
return _WordList; |
| 192 | 188 |
} |
| 193 | 189 |
|
| 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 |
- |
|
| 210 | 190 |
/// <summary> |
| 211 | 191 |
/// Checks to see if the proper file exists that contains the appropriate words. |
| 212 | 192 |
/// </summary> |
| ... | ... |
@@ -0,0 +1,28 @@ |
| 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 |
+} |
|
| 0 | 29 |