I've been developing a program to find passwords in a game called keep talking and nobody explodes, in which one of the challenges is to find the correct 5-letter password from a list of passwords. To solve it you are given 6 possible letters for each cell of the word (for example in the first column the letters could appear (randomly):
a
or
q
w
e
so the possible passwords are: about, again, which, where and every, because those are the passwords that start with those letters, in the following columns you are given more letters until you can determine the correct password.
I am trying to create a program in C ++ to find the password automatically, but I ran into a problem, when discarding bad passwords I end up with a code like this:
Here, for example, if none of the letters is an "a", I determine all the passwords that have the a in that position to be incorrect:
if(letra1 != a && letra2 != a && letra3 != a && letra4 != a && letra5 != a && letra6 != a){
again, after, about = 0
}
But this leaves me with an ugly code in which I have to use the letter I'm checking many times, try to do this:
if(letra1, letra2, letra3, letra4, letra5, letra6 != a){
again, after, about = 0;
}
But C ++ seems not to read that as I expected.
Does anyone know of any way to solve this problem? Or maybe someone who can leave me a program that uses lists / arrays? I would have tried to use a list of elements, but that is very advanced for me.
If someone has a suggestion of a simpler way to achieve this, I would also appreciate it. :)