Sudoku.Generate9.generatePosition C# (CSharp) Method

generatePosition() public method

public generatePosition ( int table, int value ) : ].int[
table int
value int
return ].int[
        public int[,] generatePosition(int[,] table, int value)
        {
            int[,] gen = new int[9, 9];
            Random r = new Random();
            int x, y;

            for (int i = 0; i < value; i++)
            {
                x = r.Next(9);
                y = r.Next(9);

                if (gen[x, y] != 0 && i != 0)
                {
                    i--;
                }
                else
                {
                    gen[x, y] = table[x, y];
                }

                gen[x, y] = table[x, y];
            }
            return gen;
        }

Usage Example

 public void testGenOK3()
 {
     solve s = new solve();
     GenerateNumber g = new Generate9();
     LevelChooser lv = new Chooselv9();
     int[,] test = new int[9, 9];
     Assert.AreNotEqual(test, g.generatePosition(s.getSolve9x9(), lv.selectedlv("Hard")));
 }
All Usage Examples Of Sudoku.Generate9::generatePosition