diff options
| author | Nicolas James <Eele1Ephe7uZahRie@tutanota.com> | 2025-02-13 18:00:17 +1100 |
|---|---|---|
| committer | Nicolas James <Eele1Ephe7uZahRie@tutanota.com> | 2025-02-13 18:00:17 +1100 |
| commit | 98cef5e9a772602d42acfcf233838c760424db9a (patch) | |
| tree | 5277fa1d7cc0a69a0f166fcbf10fd320f345f049 /comp6771/1/src/word_ladder.h | |
initial commit
Diffstat (limited to 'comp6771/1/src/word_ladder.h')
| -rw-r--r-- | comp6771/1/src/word_ladder.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/comp6771/1/src/word_ladder.h b/comp6771/1/src/word_ladder.h new file mode 100644 index 0000000..ef0f04a --- /dev/null +++ b/comp6771/1/src/word_ladder.h @@ -0,0 +1,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 |
