From 98cef5e9a772602d42acfcf233838c760424db9a Mon Sep 17 00:00:00 2001 From: Nicolas James Date: Thu, 13 Feb 2025 18:00:17 +1100 Subject: initial commit --- comp6771/1/src/main.cpp | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 comp6771/1/src/main.cpp (limited to 'comp6771/1/src/main.cpp') diff --git a/comp6771/1/src/main.cpp b/comp6771/1/src/main.cpp new file mode 100644 index 0000000..94c8e9f --- /dev/null +++ b/comp6771/1/src/main.cpp @@ -0,0 +1,39 @@ +#include + +#include "word_ladder.h" + +// Please note: it's not good practice to test your code via a main function +// that does printing. Instead, you should be using your test folder. This file +// should only really be used for more "primitive" debugging as we know that +// working solely with test frameworks might be overwhelming for some. + +namespace { + +void print_generate(const std::string& from, const std::string& to, + const auto& lexicon) { + const auto ladder = word_ladder::generate(from, to, lexicon); + std::cout << from << ':' << to << " has " << std::size(ladder) + << " solutions\n"; + for (const auto& solution : ladder) { + std::cout << " "; + for (const auto& word : solution) { + std::cout << word << ' '; + } + std::cout << '\n'; + } + std::cout << '\n'; +} + +} // namespace + +auto main() -> int { + const auto english_lexicon = word_ladder::read_lexicon("./english.txt"); + + print_generate("at", "it", english_lexicon); + print_generate("fly", "sky", english_lexicon); + print_generate("code", "data", english_lexicon); + print_generate("work", "play", english_lexicon); + print_generate("awake", "sleep", english_lexicon); + print_generate("airplane", "tricycle", english_lexicon); + print_generate("atlases", "cabaret", english_lexicon); +} -- cgit v1.2.3