Working
This commit is contained in:
		@@ -151,9 +151,8 @@ int main(int argc, char *argv[]) {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    std::vector<std::string> dictionary = readDictionary(wordLength);
 | 
					    std::vector<std::string> dictionary = readDictionary(wordLength);
 | 
				
			||||||
    std::vector<char> guessProgress(wordLength, '-');
 | 
					    std::string guessProgress(wordLength, '-');
 | 
				
			||||||
    std::cout << "So far: ";
 | 
					    std::cout << "Word: " << guessProgress << std::endl;
 | 
				
			||||||
    printContainer(guessProgress);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    std::vector<char> guessedChars;
 | 
					    std::vector<char> guessedChars;
 | 
				
			||||||
    size_t wrongAttempts = 0;
 | 
					    size_t wrongAttempts = 0;
 | 
				
			||||||
@@ -186,6 +185,14 @@ int main(int argc, char *argv[]) {
 | 
				
			|||||||
                });
 | 
					                });
 | 
				
			||||||
            currentlyThinkingOf = biggestEntry->first;
 | 
					            currentlyThinkingOf = biggestEntry->first;
 | 
				
			||||||
            dictionary = biggestEntry->second;
 | 
					            dictionary = biggestEntry->second;
 | 
				
			||||||
 | 
					        }else{
 | 
				
			||||||
 | 
					            std::string &word = dictionary[0];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            for (size_t i = 0; i < word.size(); i++) {
 | 
				
			||||||
 | 
					                if (word[i] != guess)
 | 
				
			||||||
 | 
					                    continue;
 | 
				
			||||||
 | 
					                currentlyThinkingOf[i] = guess;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (showRemainingWords) {
 | 
					        if (showRemainingWords) {
 | 
				
			||||||
@@ -208,11 +215,12 @@ int main(int argc, char *argv[]) {
 | 
				
			|||||||
            wrongAttempts++;
 | 
					            wrongAttempts++;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        std::cout << "So far: ";
 | 
					 | 
				
			||||||
        printContainer(guessProgress); // Display the current guessed word state
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        guessedChars.push_back(guess);
 | 
					        guessedChars.push_back(guess);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        std::cout << "Used letters: ";
 | 
				
			||||||
 | 
					        printContainer(guessedChars, " ");
 | 
				
			||||||
 | 
					        std::cout << "Word: " << currentlyThinkingOf << std::endl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Check if all the characters in the final word have been guessed
 | 
					        // Check if all the characters in the final word have been guessed
 | 
				
			||||||
        hasWon = std::all_of(guessProgress.begin(), guessProgress.end(),
 | 
					        hasWon = std::all_of(guessProgress.begin(), guessProgress.end(),
 | 
				
			||||||
                             [](char c) { return c != '-'; });
 | 
					                             [](char c) { return c != '-'; });
 | 
				
			||||||
@@ -221,7 +229,7 @@ int main(int argc, char *argv[]) {
 | 
				
			|||||||
    } while (!hasWon && !hasLost);
 | 
					    } while (!hasWon && !hasLost);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const char *out = hasWon ? "congratulations! You've won! 🎉" : "you lost.";
 | 
					    const char *out = hasWon ? "congratulations! You've won! 🎉" : "you lost.";
 | 
				
			||||||
    std::cout << "Well, the word was '" << dictionary[0] << "', " << out
 | 
					    std::cout << "The word was '" << dictionary[0] << "', " << out
 | 
				
			||||||
              << std::endl;
 | 
					              << std::endl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return 0;
 | 
					    return 0;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user