Skip to content
Permalink
Browse files

LetterBoxedSolver - load StrTrie from file

  • Loading branch information...
bobbymcr committed May 26, 2019
1 parent 8814a06 commit d74f4bf61706c36dc3c704d0da1adadb927b3fdd
Showing with 34 additions and 24 deletions.
  1. +34 −24 src/LetterBoxedSolver.Native/LetterBoxedSolver.cpp
@@ -1,34 +1,44 @@
#include "Str.h"
#include "StrTrie.h"
#include "LetterBoxStr.h"
#include "Stopwatch.h"
#include <iomanip>
#include <fstream>
#include <sstream>

using namespace std;
using namespace Words;

void Print(const Str& s)
void Log(const char* line)
{
size_t length = s.length();
cout << "(" << length << ") [" << s << "]\r\n";
static Stopwatch watch;

cout << "[" << watch.elapsed() << "] " << line << "\r\n";
}

int main()
int main(int argc, const char** argv)
{
Str s;
s = s + 'A'_c;
s = s + 'B'_c;
s = s + 'C'_c;
s = s + 'D'_c;
s = s + 'E'_c;
s = s + 'F'_c;
s = s + 'G'_c;
s = s + 'H'_c;
s = s + 'I'_c;
s = s + 'J'_c;
s = s + 'K'_c;
s = s + 'L'_c;

Print(s);

Str t = "ZYXWVUTSRQPO";
Print(t);
if (argc != 3)
{
cout << "Please specify a Letter Boxed puzzle and a word list file.\r\n";
return 1;
}

cout << setiosflags(ios::fixed) << setprecision(3);
LetterBoxStr box(argv[1]);

Log("Loading trie...");
ifstream file(argv[2]);
if (file.fail())
{
cout << "Could not open file '" << argv[2] << "'.\r\n";
return 1;
}

StrTrie trie(file);

stringstream ss;
ss << "Loaded " << trie.size() << " words.";
Log(ss.str().c_str());

return 0;
}
}

0 comments on commit d74f4bf

Please sign in to comment.
You can’t perform that action at this time.