aboutsummaryrefslogtreecommitdiff
path: root/comp6771/1/src/main.cpp
blob: 94c8e9f7a08fbd998862c2a3aa19af0e1ffed25d (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
32
33
34
35
36
37
38
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);
}