Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct Word {
- string word;
- bool visited;
- Word* parent = nullptr;
- //can i do this???
- char action = NULL;
- int position = NULL;
- char next = NULL;
- Word() {}
- Word(string word_in, bool visited_in): word(word_in), visited(visited_in) {}
- };
- bool words_letter_off(Word &key_word, deque<Word> &passed_deque, vector<Word>
- &dictionary, bool length, bool change, string &end_word) {
- //if the word is a letter off, push it onto the deque.
- Word word_to_add;
- for (unsigned int i = 0; i < dictionary.size(); i++) {
- //while we didn't find the word...
- bool add_word = letter_off(length, change, dictionary[i], key_word);
- if (add_word && !dictionary[i].visited) {
- dictionary[i].visited = true;
- dictionary[i].parent = &key_word;
- word_to_add = dictionary[i];
- passed_deque.push_back(word_to_add);
- if (word_to_add.word == end_word) {
- return true;
- }
- }
- }
- return false;
- }
- EXCERPT OF CODE!!!!!! :
- while (!found) {
- if (stack) {
- deque.pop_back();
- found = words_letter_off(current_word, deque, words,length, change, end);
- //if its a stack, check the to-be popped off ref, if queue change.
- if (deque.empty()) {
- break;
- //if we didn't find the word
- }
- current_word = deque.back();
- //update current word to the last one in the stack
- }
- else if (queue) {
- deque.pop_front();
- found = words_letter_off(current_word, deque, words, length, change, end);
- if (deque.empty()) {
- break;
- //if we didn't find the word
- }
- current_word = deque.front();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement