aboutsummaryrefslogtreecommitdiff
path: root/comp6771/1/src/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'comp6771/1/src/main.cpp')
-rw-r--r--comp6771/1/src/main.cpp39
1 files changed, 39 insertions, 0 deletions
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 <iostream>
+
+#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);
+}