-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwspuzzle.cpp
More file actions
45 lines (37 loc) · 1.16 KB
/
Copy pathwspuzzle.cpp
File metadata and controls
45 lines (37 loc) · 1.16 KB
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
38
39
40
41
42
43
44
45
#include <iostream>
#include <string>
#include <vector>
#include "wordsearch.h"
constexpr int NUM_WORDS = 12;
// Reads NUM_WORDS words from the standard input stream and places them
// into a vector words. Next it reads in a word search puzzle into
// the LetterMatrix puzzle.
// (You can use command-line redirection to load all this from a file.)
void get_puzzle(std::vector<std::string>& words, LetterMatrix& puzzle) {
// Ensure word list initially is empty
words.clear();
// Load the word list
std::string word;
for (int i = 0; i < NUM_WORDS; i++) {
std::cin >> word;
words.push_back(word);
}
std::cin.ignore(1000, '\n');
// Load puzzle
std::cin >> puzzle;
}
int main() {
std::vector<std::string> word_list;
LetterMatrix puz;
get_puzzle(word_list, puz);
// Print the list of words
for (auto word : word_list)
std::cout << word << '\n';
std::cout << '\n';
// Print the puzzle
std::cout << puz << '\n';
// Solve the puzzle
auto ans = solve(puz, word_list); // undo this when complete
// Print the solution
std::cout << ans << '\n'; // undo this when complete
}