-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboggle-driver.cpp
More file actions
35 lines (32 loc) · 854 Bytes
/
boggle-driver.cpp
File metadata and controls
35 lines (32 loc) · 854 Bytes
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
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <random>
#include "boggle.h"
using namespace std;
int main(int argc, char* argv[])
{
if(argc < 4)
{
cout << "Usage: boggle-driver <size> <seed> <dictionary file>" << endl;
exit(1);
}
int size = atoi(argv[1]);
int seed = atoi(argv[2]);
vector<vector<char> > board = genBoard(size, seed);
printBoard(board);
pair<set<string>, set<string> > parsed = parseDict(string(argv[3]));
set<string> dictionary = parsed.first;
set<string> prefix = parsed.second;
set<string> found = boggle(dictionary, prefix, board);
set<string>::iterator it;
stringstream os;
for(it=found.begin();it != found.end(); ++it)
{
os << *it << ", ";
}
cout << "Found " << found.size() << " words:" << endl;
cout << os.str().substr(0,os.str().size()-2) << endl;
}