Dev Ghai commited on 2013-12-27 07:02:01
Showing 1 changed files, with 24 additions and 35 deletions.
... | ... |
@@ -114,53 +114,42 @@ namespace Boggle |
114 | 114 |
|
115 | 115 |
BoggleBoard board = new BoggleBoard(boardSideLength, boardString); |
116 | 116 |
board.Print(); |
117 |
- BoggleSolver solution = new BoggleSolver(board, bl, minWordLength); |
|
117 |
+ BoggleSolver solver = new BoggleSolver(board, bl, minWordLength); |
|
118 |
+ st.Reset(); |
|
118 | 119 |
st.Start(); |
119 |
- //HashSet<WordOnBoard> wordsUnThreaded = solution.GetWordsOnBoard(false); |
|
120 |
- //st.Stop(); |
|
121 |
- //PrintWords(wordsUnThreaded); |
|
120 |
+ HashSet<WordOnBoard> wordsUnThreaded = solver.GetWordsOnBoard(false); |
|
121 |
+ st.Stop(); |
|
122 |
+ PrintWords(wordsUnThreaded); |
|
122 | 123 |
|
123 |
- //Console.WriteLine("Got solution in {0} ms. Number of words (unthreaded): {1}", st.ElapsedMilliseconds, wordsUnThreaded.Count); |
|
124 |
- //Console.WriteLine("Press any key to run in threaded mode."); |
|
125 |
- //Console.ReadKey(); |
|
124 |
+ Console.WriteLine("Got solution in {0} ms. Number of words (UNTHREADED): {1}\n\n", st.ElapsedMilliseconds, wordsUnThreaded.Count); |
|
125 |
+ st.Reset(); |
|
126 | 126 |
st.Start(); |
127 |
- HashSet<WordOnBoard> wordsThreaded = solution.GetWordsOnBoard(true); |
|
128 |
- //wordsThreaded.ExceptWith(wordsUnThreaded); |
|
127 |
+ HashSet<WordOnBoard> wordsThreaded = solver.GetWordsOnBoard(true); |
|
129 | 128 |
st.Stop(); |
130 | 129 |
st.Reset(); |
131 | 130 |
PrintWords(wordsThreaded); |
132 |
- Console.WriteLine("Got solution in {0} ms. Number of words (threaded): {1}.", st.ElapsedMilliseconds, wordsThreaded.Count); |
|
133 |
- |
|
134 |
- |
|
135 |
- |
|
136 |
- |
|
137 |
- //if (wordsUnThreaded.Count > wordsThreaded.Count) |
|
138 |
- //{ |
|
139 |
- // wordsUnThreaded.ExceptWith(wordsThreaded); |
|
140 |
- // Console.WriteLine("Words in unthreaded collection that are not in threaded collection:"); |
|
141 |
- // PrintWords(wordsUnThreaded); |
|
142 |
- //} |
|
143 |
- //if (wordsThreaded.Count > wordsUnThreaded.Count) |
|
144 |
- //{ |
|
145 |
- // wordsThreaded.ExceptWith(wordsUnThreaded); |
|
146 |
- // Console.WriteLine("Words in threaded collection that are not in unthreaded collection:"); |
|
147 |
- // PrintWords(wordsThreaded); |
|
148 |
- //} |
|
131 |
+ Console.WriteLine("\nGot solution in {0} ms. Number of words (THREADED): {1}.", st.ElapsedMilliseconds, wordsThreaded.Count); |
|
149 | 132 |
|
150 |
- //wordsUnThreaded.RemoveWhere(WordsWithLowestScore); |
|
151 |
- //Console.WriteLine("***Removed words with score 1.***"); |
|
152 |
- //PrintWords(wordsUnThreaded); |
|
153 |
- Console.ReadKey(); |
|
133 |
+ Console.WriteLine("Time for sanity checks... comparing solutions from threaded and non-threaded mode."); |
|
134 |
+ if (wordsThreaded.Count == wordsUnThreaded.Count) |
|
135 |
+ { |
|
136 |
+ Console.WriteLine("\nALL GOOD!"); |
|
154 | 137 |
} |
155 |
- |
|
156 |
- private static bool WordsWithLowestScore(WordOnBoard word) |
|
138 |
+ if (wordsUnThreaded.Count > wordsThreaded.Count) |
|
157 | 139 |
{ |
158 |
- if (word.Score == Constants.MIN_SCORE) |
|
140 |
+ wordsUnThreaded.ExceptWith(wordsThreaded); |
|
141 |
+ Console.WriteLine("Words in unthreaded collection that are not in threaded collection:"); |
|
142 |
+ PrintWords(wordsUnThreaded); |
|
143 |
+ } |
|
144 |
+ if (wordsThreaded.Count > wordsUnThreaded.Count) |
|
159 | 145 |
{ |
160 |
- return true; |
|
146 |
+ wordsThreaded.ExceptWith(wordsUnThreaded); |
|
147 |
+ Console.WriteLine("Words in threaded collection that are not in unthreaded collection:"); |
|
148 |
+ PrintWords(wordsThreaded); |
|
161 | 149 |
} |
162 | 150 |
|
163 |
- return false; |
|
151 |
+ Console.WriteLine("\nPress any key to exit."); |
|
152 |
+ Console.ReadKey(); |
|
164 | 153 |
} |
165 | 154 |
} |
166 | 155 |
} |
167 | 156 |