/// <summary> /// Returns the input and the desired output for the given case study /// </summary> /// <returns>Returns CaseStudy View</returns> public ActionResult CaseStudy() { CaseStudyModel caseStudyModel = new CaseStudyModel(); caseStudyModel.inputArray = new int[][] { new int[] { 1, 2, 3, 4, 5 }, new int[] { 6, 7, 8, 9, 10 }, new int[] { 11, 12, 13, 14, 15 }, new int[] { 16, 17, 18, 19, 20 }, new int[] { 21, 22, 23, 24, 25 } }; caseStudyModel.outPut1 = RotateMatrix(5, 5, caseStudyModel.inputArray); caseStudyModel.outPut2 = RotateMatrix(5, 5, caseStudyModel.outPut1); return(View(caseStudyModel)); }
public ActionResult GenericType(CaseStudyModel caseStudyModel) { if (ModelState.IsValid) { //Input array caseStudyModel.inputArray = new int[][] { new int[] { 1, 2, 3, 4, 5 }, new int[] { 6, 7, 8, 9, 10 }, new int[] { 11, 12, 13, 14, 15 }, new int[] { 16, 17, 18, 19, 20 }, new int[] { 21, 22, 23, 24, 25 } }; caseStudyModel.genericOutput = caseStudyModel.inputArray; //After 25 rotations the value is going to be repeated, by taking mod of 25 reduces the number of computations to atmost 25 times int rotationTimes = caseStudyModel.rotationTimes % 25; //Rotates the array for the given times for (int i = 0; i < rotationTimes; i++) { caseStudyModel.genericOutput = RotateMatrix(5, 5, caseStudyModel.genericOutput); } return(View(caseStudyModel)); } else { return(View()); } }