Advertisement
Guest User

Untitled

a guest
Jan 28th, 2015
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. struct Word {
  2. string word;
  3. bool visited;
  4. Word* parent = nullptr;
  5.  
  6. //can i do this???
  7. char action = NULL;
  8. int position = NULL;
  9. char next = NULL;
  10.  
  11. Word() {}
  12.  
  13. Word(string word_in, bool visited_in): word(word_in), visited(visited_in) {}
  14. };
  15.  
  16.  
  17.  
  18.  
  19.  
  20. bool words_letter_off(Word &key_word, deque<Word> &passed_deque, vector<Word>
  21. &dictionary, bool length, bool change, string &end_word) {
  22.  
  23. //if the word is a letter off, push it onto the deque.
  24. Word word_to_add;
  25. for (unsigned int i = 0; i < dictionary.size(); i++) {
  26. //while we didn't find the word...
  27. bool add_word = letter_off(length, change, dictionary[i], key_word);
  28. if (add_word && !dictionary[i].visited) {
  29. dictionary[i].visited = true;
  30. dictionary[i].parent = &key_word;
  31. word_to_add = dictionary[i];
  32. passed_deque.push_back(word_to_add);
  33. if (word_to_add.word == end_word) {
  34. return true;
  35. }
  36. }
  37.  
  38. }
  39. return false;
  40. }
  41.  
  42.  
  43.  
  44.  
  45. EXCERPT OF CODE!!!!!! :
  46.  
  47.  
  48.  
  49.  
  50. while (!found) {
  51. if (stack) {
  52. deque.pop_back();
  53. found = words_letter_off(current_word, deque, words,length, change, end);
  54. //if its a stack, check the to-be popped off ref, if queue change.
  55.  
  56. if (deque.empty()) {
  57. break;
  58. //if we didn't find the word
  59. }
  60.  
  61. current_word = deque.back();
  62.  
  63. //update current word to the last one in the stack
  64. }
  65.  
  66. else if (queue) {
  67. deque.pop_front();
  68. found = words_letter_off(current_word, deque, words, length, change, end);
  69.  
  70. if (deque.empty()) {
  71. break;
  72. //if we didn't find the word
  73. }
  74.  
  75.  
  76. current_word = deque.front();
  77.  
  78. }
  79.  
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement