/*---- signature: guess_match: string string -> string purpose: expects a word of the day and a guessed word, and returns string giving the match-color-results for guessed word as follows: * if the letter in a position matches, append "green " * if the letter in a position does not match, but IS elsewhere in the word of the day, append "gold " * otherwise, append "gray " tests: guess_match("great", "brake") == "gray green gold gray gold " guess_match("stomp", "bugle") == "gray gray gray gray gray " by: Sharon Tuttle last modified: 2022-09-01 ----*/ #include <cstdlib> #include <iostream> #include <string> #include <cmath> #include "letter_match.h" #include "letter_elsewhere.h" using namespace std; string guess_match(string word_of_day, string word_guess ) { string match_result = ""; int guess_len = word_guess.length(); for (int i = 0; i < guess_len; i++) { if (letter_match(word_of_day, word_guess, i)) { match_result += "green "; } else if (letter_elsewhere(word_of_day, word_guess, i)) { match_result += "gold "; } else { match_result += "gray "; } } return match_result; }