Exemplo n.º 1
0
        public ActionResult Solve(SudukoModel data)
        {
            Helper obj = new Helper(data);

            _sudukoModel = obj.SolveSudoko();
            return(RedirectToAction("Index", new { id = JsonConvert.SerializeObject(_sudukoModel), session = "" }));
        }
Exemplo n.º 2
0
 public IActionResult Index(String id, string session)
 {
     if (string.IsNullOrEmpty(id))
     {
         var getfile = _sudokuInitializer.getAllSudukoFiles("");
         ViewBag.Locations = getfile;
         _sudukoModel      = _sudokuInitializer.ConvertToSudocoTable(_sudokuInitializer.FetchDatafromFile(getfile[0].Value));
     }
     else
     {
         var getfile = _sudokuInitializer.getAllSudukoFiles(HttpUtility.UrlDecode(session));
         ViewBag.Locations = getfile;
         _sudukoModel      = JsonConvert.DeserializeObject <SudukoModel>(id);
     }
     return(View(_sudukoModel));
 }
Exemplo n.º 3
0
        public SudukoModel ConvertToSudocoTable(int[] ProblemArray)
        {
            var data = new SudukoModel();

            data.SudData = new int[9][];//Row Declaration.
            for (var i = 0; i < data.SudData.Length; i++)
            {
                data.SudData[i] = new int[9];//Column Declaration
            }
            Func <int, int, int> FindCurrentCell = (Row, Column) => (Row * 9) + Column;

            //Push the values into the array.
            for (var i = 0; i < data.SudData.Length; i++)
            {
                for (var j = 0; j < data.SudData.Length; j++)
                {
                    data.SudData[i][j] = ProblemArray[FindCurrentCell(i, j)];
                }
            }
            return(data);
        }
Exemplo n.º 4
0
 public IActionResult indexchange(string value)
 {
     _sudukoModel = _sudokuInitializer.ConvertToSudocoTable(_sudokuInitializer.FetchDatafromFile(value));
     return(RedirectToAction("Index", new { id = JsonConvert.SerializeObject(_sudukoModel), session = value }));
 }