diff --git a/Sources/CoreLibrary/Code.cs b/Sources/CoreLibrary/Code.cs index 81b3b61..8720ed3 100644 --- a/Sources/CoreLibrary/Code.cs +++ b/Sources/CoreLibrary/Code.cs @@ -84,16 +84,15 @@ namespace CoreLibrary { // Mon code est le code correct, l'autre code est celui qui teste - Indicateur[] indicateurs = []; if (!EstComplet() || !autreCode.EstComplet()) return indicateurs; - Jeton?[] mesJetons = Jetons().ToArray(); - Jeton?[] sesJetons = autreCode.Jetons().ToArray(); + List mesJetons = new List(Jetons()); + List sesJetons = new List(autreCode.Jetons()); - for (int i = 0; i < mesJetons.Length; ++i) + for (int i = 0; i < mesJetons.Count; ++i) { Jeton? monJeton = mesJetons[i]; Jeton? sonJeton = sesJetons[i]; @@ -107,25 +106,16 @@ namespace CoreLibrary } - for (int i = 0; i < sesJetons.Length; ++i) + for (int i = 0; i < sesJetons.Count; ++i) { Jeton? sonJeton = sesJetons[i]; - - if (sonJeton.HasValue) + + if (sonJeton.HasValue && mesJetons.Contains(sonJeton.Value)) { - for (int j = 0; j < mesJetons.Length; ++j) - { - Jeton? monJeton = mesJetons[j]; - - if (monJeton.HasValue && sonJeton.Value.Couleur.Equals(monJeton.Value.Couleur)) - { - indicateurs = indicateurs.Append(Indicateur.BONNECOULEUR).ToArray(); - mesJetons[j] = null; - sesJetons[i] = null; - break; - } - - } + indicateurs = indicateurs.Append(Indicateur.BONNECOULEUR).ToArray(); + mesJetons[mesJetons.IndexOf(sonJeton.Value)] = null; + sesJetons[i] = null; + break; } }