samedi 27 juin 2015

comparing strings to characters and generating keys? [on hold]

ok there is no easy way to put this in the title.

I know I have no code but I have no idea how do this at all.

ok. so here is what I need to do. I have a vector of strings. all of these words are the same length (but the word length can change). and its a contest. the user picks a letter. and I am supposed to find words that have the letter. but its a little more complicated than that. lets say the vector has 4 letter words in it. words such as ball, bell, boby, mark, abba, baab. and the keys for each word in order if I guessed the letter b. b---, b---, b-b-, ----, -bb-, b--b. so you see. basically the key is the word with the letters that are not guessed replaced with a '-'. now lets say that there are 10 words with key b---, 5 word with key b--b, 1 word with key ----, 2 words with key ---b. there are a lot of possibilities for a key depending on how many letters. then I am supposed to delete all the words with the keys that are not the most. so the words with the most frequent key stay. the question is. how do I do all of that.

now I know its easiest to make two vectors. one to keep the keys. and one to keep how many times a key occurs both vectors have corresponding indexes to make my life easier. or I guess I could make a vector that stores a structure of both the key and how many times it occurs. but lets ignore that. how do I generate the keys from the words. and how do I figure out how many times a key occurred. and then how do I delete the words or move the words with the most frequent key somewhere else.

again. I could guess more than once. if I guess with letter c the second time. then the key could be a combination of b and c in words. b--c. bbcc. b-c- but since I had picked b first then b stays in the buffer (except if at first we selected the key ---- as most frequent) then the second guess would basically be the first guess with words that do not contain the letter b. because the most frequent key was ----. this is too long. but I appreciate some help.

edit. I basically need to get the most words with the most common key separated from a vector of strings into their own vector of strings.

Aucun commentaire:

Enregistrer un commentaire