diff options
Diffstat (limited to 'Algorithms/Part-II/4-Boggle/BoggleSolver.java')
-rw-r--r-- | Algorithms/Part-II/4-Boggle/BoggleSolver.java | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/Algorithms/Part-II/4-Boggle/BoggleSolver.java b/Algorithms/Part-II/4-Boggle/BoggleSolver.java new file mode 100644 index 0000000..49633cd --- /dev/null +++ b/Algorithms/Part-II/4-Boggle/BoggleSolver.java @@ -0,0 +1,37 @@ +/* vim: set expandtab tabstop=4 shiftwidth=4 : */ + +public class BoggleSolver +{ + // assume each word in the dictionary contains only [A-Z] + public BoggleSolver(String[] dictionary) + { + } + + // Returns the set of all valid words in the given Boggle board + public Iterable<String> getAllValidWords(BoggleBoard board) + { + return null; + } + + // Returns the score if it is in the dictionary, zero otherwise. + // assume the word contains only [A-Z] + public int scoreOf(String word) + { + return -1; + } + + public static void main(String[] args) + { + In in = new In(args[0]); + String[] dictionary = in.readAllStrings(); + BoggleSolver solver = new BoggleSolver(dictionary); + BoggleBoard board = new BoggleBoard(args[1]); + int score = 0; + for (String word : solver.getAllValidWords(board)) + { + StdOut.println(word); + score += solver.scoreOf(word); + } + StdOut.println("Score = " + score); + } +} |