leo064 / memory-game

Jogo da memória em C# (console application) requisitado pela matéria de DS - 2A 2BIM
0 stars 0 forks source link

Generate numbers pairs of 1-6 without repeat #1

Closed leo064 closed 3 years ago

leo064 commented 3 years ago

The code generate and impress the numbers correctely, but they repeat.

Teacher Saiz says:

"For each number you enter, search the vector, the numbers you already have, to find out how many times it appears. This search can be done with foreach, for example. Each time the number is repeated, add 1 to a counter So it goes in a loop from which it only comes out if the counter is less than 2. This is what allows you to generate a repeated number just 2x (to form pairs) All of this will be within a for, to generate 12 numbers"

leo064 commented 3 years ago

I followed a teacher diferent path to solve this Issue. I utilized Fisher-Yates Algorithm to shuffle a array pre-defined rather randomize and get head pain in thinking about the "without repeat" question.