blob: ef0f04a7f0cc6eb7a61583e1f2a2ebdb433dd0fa (
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
|
#ifndef COMP6771_WORD_LADDER_H
#define COMP6771_WORD_LADDER_H
#include <algorithm>
#include <filesystem>
#include <fstream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
namespace word_ladder {
// Given a file path to a newline-separated list of words...
// Loads those words into an unordered set and returns it.
auto read_lexicon(const std::string& path) -> std::unordered_set<std::string>;
// Given a start word and destination word, returns all the shortest possible
// paths from the start word to the destination, where each word in an
// individual path is a valid word per the provided lexicon. Preconditions:
// - from.size() == to.size()
// - lexicon.contains(from)
// - lexicon.contains(to)
auto generate(const std::string& from, const std::string& to,
const std::unordered_set<std::string>& lexicon)
-> std::vector<std::vector<std::string>>;
} // namespace word_ladder
#endif // COMP6771_WORD_LADDER_H
|