blob: 49633cdf77d4bf5851acfec31d15040f59089c5d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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);
}
}
|