private void GenerateRandom(int count) { Random random = new Random(); if (count == 0) { return; } if (count > Sudoku.max * Sudoku.max) { return; } sudoku.ClearMap(); for (int c = 0; c < count; c++) { int x, y, d; int loop = 777; do { x = random.Next(0, Sudoku.max); y = random.Next(0, Sudoku.max); d = random.Next(1, Sudoku.max + 1); }while (--loop > 0 && !sudoku.PlaceDigit(x, y, d)); } Console.SetCursorPosition(20, 5); Console.WriteLine("Puzzle ready"); }