From 50f58bf44a1d0a16dbc43a7b9f8472af052eee32 Mon Sep 17 00:00:00 2001 From: Ramy Berrekia Date: Tue, 16 Dec 2025 22:51:57 +0300 Subject: [PATCH 01/12] Update Green.cs --- Lab6/Green.cs | 305 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 293 insertions(+), 12 deletions(-) diff --git a/Lab6/Green.cs b/Lab6/Green.cs index 16b248c3..bb9478c9 100644 --- a/Lab6/Green.cs +++ b/Lab6/Green.cs @@ -1,15 +1,20 @@ -using System.Linq; +using System.Linq; using System.Runtime.InteropServices; namespace Lab6 { public class Green { + public delegate void Sorting(int[] row); + public void Task1(ref int[] A, ref int[] B) { // code here - + if (A == null || B == null) { A = null; B = null; return; } + DeleteMaxElement(ref A); + DeleteMaxElement(ref B); + A = CombineArrays(A, B); // end } @@ -17,7 +22,16 @@ public void Task2(int[,] matrix, int[] array) { // code here - + if (matrix == null || array == null) return; + int rows = matrix.GetLength(0); + int cols = matrix.GetLength(1); + if (array.Length != rows) return; + for (int i = 0; i < rows; i++) + { + int col; + int max = FindMaxInRow(matrix, i, out col); + if (max < array[i]) matrix[i, col] = array[i]; + } // end } @@ -25,7 +39,13 @@ public void Task3(int[,] matrix) { // code here - + if (matrix == null) return; + int n = matrix.GetLength(0); + int m = matrix.GetLength(1); + if (n != m) return; + int row, col; + FindMax(matrix, out row, out col); + SwapColWithDiagonal(matrix, col); // end } @@ -33,7 +53,27 @@ public void Task4(ref int[,] matrix) { // code here - + if (matrix == null) { matrix = null; return; } + int rows = matrix.GetLength(0); + int cols = matrix.GetLength(1); + bool[] keep = new bool[rows]; + int k = 0; + for (int i = 0; i < rows; i++) + { + bool hasZero = false; + for (int j = 0; j < cols; j++) { if (matrix[i, j] == 0) { hasZero = true; break; } } + keep[i] = !hasZero; + if (keep[i]) k++; + } + int[,] res = new int[k, cols]; + int r = 0; + for (int i = 0; i < rows; i++) + { + if (!keep[i]) continue; + for (int j = 0; j < cols; j++) res[r, j] = matrix[i, j]; + r++; + } + matrix = res; // end } @@ -42,7 +82,18 @@ public int[] Task5(int[,] matrix) int[] answer = null; // code here - + if (matrix == null) return null; + int n = matrix.GetLength(0); + int m = matrix.GetLength(1); + if (n != m) return null; + int[] res = new int[n]; + for (int i = 0; i < n; i++) + { + int min = matrix[i, i]; + for (int j = i; j < m; j++) if (matrix[i, j] < min) min = matrix[i, j]; + res[i] = min; + } + answer = res; // end return answer; @@ -52,7 +103,10 @@ public int[] Task6(int[,] A, int[,] B) int[] answer = null; // code here - + if (A == null || B == null) return null; + int[] sA = SumPositiveElementsInColumns(A); + int[] sB = SumPositiveElementsInColumns(B); + answer = CombineArrays(sA, sB); // end return answer; @@ -61,7 +115,16 @@ public void Task7(int[,] matrix, Sorting sort) { // code here - + if (matrix == null || sort == null) return; + int rows = matrix.GetLength(0); + int cols = matrix.GetLength(1); + for (int i = 0; i < rows; i++) + { + int[] rowArr = new int[cols]; + for (int j = 0; j < cols; j++) rowArr[j] = matrix[i, j]; + sort(rowArr); + for (int j = 0; j < cols; j++) matrix[i, j] = rowArr[j]; + } // end } @@ -70,7 +133,11 @@ public int Task8(double[] A, double[] B) int answer = 0; // code here - + if (A == null || B == null || A.Length != 3 || B.Length != 3) return 0; + double a1 = GeronArea(A[0], A[1], A[2]); + double a2 = GeronArea(B[0], B[1], B[2]); + if (a1 == 0 && a2 == 0) answer = 0; + else answer = (a1 > a2) ? 1 : 2; // end return answer; @@ -79,7 +146,16 @@ public void Task9(int[,] matrix, Action sorter) { // code here - + if (matrix == null || sorter == null) return; + int rows = matrix.GetLength(0); + int cols = matrix.GetLength(1); + for (int i = 0; i < rows; i += 2) + { + int[] row = new int[cols]; + for (int j = 0; j < cols; j++) row[j] = matrix[i, j]; + sorter(row); + ReplaceRow(matrix, i, row); + } // end } @@ -88,10 +164,215 @@ public double Task10(int[][] array, Func func) double res = 0; // code here - + if (array == null || func == null) return 0; + res = func(array); // end return res; } + + public void DeleteMaxElement(ref int[] array) + { + if (array == null) { array = null; return; } + if (array.Length == 0) return; + int max = array[0], idx = 0; + for (int i = 1; i < array.Length; i++) if (array[i] > max) { max = array[i]; idx = i; } + int[] res = new int[array.Length - 1]; + int w = 0; + for (int i = 0; i < array.Length; i++) if (i != idx) res[w++] = array[i]; + array = res; + } + public int[] CombineArrays(int[] A, int[] B) + { + if (A == null || B == null) return null; + int[] res = new int[A.Length + B.Length]; + int k = 0; + for (int i = 0; i < A.Length; i++) res[k++] = A[i]; + for (int i = 0; i < B.Length; i++) res[k++] = B[i]; + return res; + } + public int FindMaxInRow(int[,] matrix, int row, out int col) + { + col = 0; + int cols = matrix.GetLength(1); + int max = matrix[row, 0]; + for (int j = 1; j < cols; j++) if (matrix[row, j] > max) { max = matrix[row, j]; col = j; } + return max; + } + public void FindMax(int[,] matrix, out int row, out int col) + { + row = 0; col = 0; + int r = matrix.GetLength(0); + int c = matrix.GetLength(1); + int max = matrix[0, 0]; + for (int i = 0; i < r; i++) + for (int j = 0; j < c; j++) + { + int v = matrix[i, j]; + if (v > max) { max = v; row = i; col = j; } + } + } + public void SwapColWithDiagonal(int[,] matrix, int col) + { + int n = matrix.GetLength(0); + int m = matrix.GetLength(1); + if (n != m || col < 0 || col >= m) return; + for (int i = 0; i < n; i++) + { + int tmp = matrix[i, i]; + matrix[i, i] = matrix[i, col]; + matrix[i, col] = tmp; + } + } + public void RemoveRow(ref int[,] matrix, int row) + { + if (matrix == null) { matrix = null; return; } + int n = matrix.GetLength(0); + int m = matrix.GetLength(1); + if (row < 0 || row >= n) return; + int[,] res = new int[n - 1, m]; + int w = 0; + for (int i = 0; i < n; i++) + { + if (i == row) continue; + for (int j = 0; j < m; j++) res[w, j] = matrix[i, j]; + w++; + } + matrix = res; + } + public int[] GetRowsMinElements(int[,] matrix) + { + if (matrix == null) return null; + int n = matrix.GetLength(0); + int m = matrix.GetLength(1); + if (n != m) return null; + int[] res = new int[n]; + for (int i = 0; i < n; i++) + { + int min = matrix[i, i]; + for (int j = i; j < m; j++) if (matrix[i, j] < min) min = matrix[i, j]; + res[i] = min; + } + return res; + } + public int[] SumPositiveElementsInColumns(int[,] matrix) + { + int rows = matrix.GetLength(0); + int cols = matrix.GetLength(1); + int[] res = new int[cols]; + for (int j = 0; j < cols; j++) + { + int s = 0; + for (int i = 0; i < rows; i++) if (matrix[i, j] > 0) s += matrix[i, j]; + res[j] = s; + } + return res; + } + public void SortEndAscending(int[] row) + { + if (row == null || row.Length <= 1) return; + int max = row[0], idx = 0; + for (int i = 1; i < row.Length; i++) if (row[i] > max) { max = row[i]; idx = i; } + if (idx + 1 >= row.Length) return; + int len = row.Length - (idx + 1); + int[] tail = new int[len]; + for (int i = 0; i < len; i++) tail[i] = row[idx + 1 + i]; + System.Array.Sort(tail); + for (int i = 0; i < len; i++) row[idx + 1 + i] = tail[i]; + } + public void SortEndDescending(int[] row) + { + if (row == null || row.Length <= 1) return; + int max = row[0], idx = 0; + for (int i = 1; i < row.Length; i++) if (row[i] > max) { max = row[i]; idx = i; } + if (idx + 1 >= row.Length) return; + int len = row.Length - (idx + 1); + int[] tail = new int[len]; + for (int i = 0; i < len; i++) tail[i] = row[idx + 1 + i]; + System.Array.Sort(tail); + System.Array.Reverse(tail); + for (int i = 0; i < len; i++) row[idx + 1 + i] = tail[i]; + } + public double GeronArea(double a, double b, double c) + { + if (a <= 0 || b <= 0 || c <= 0) return 0; + if (a + b <= c || a + c <= b || b + c <= a) return 0; + double p = (a + b + c) / 2.0; + double s2 = p * (p - a) * (p - b) * (p - c); + return s2 <= 0 ? 0 : System.Math.Sqrt(s2); + } + public void ReplaceRow(int[,] matrix, int row, int[] array) + { + if (matrix == null || array == null) return; + int cols = matrix.GetLength(1); + if (row < 0 || row >= matrix.GetLength(0) || array.Length != cols) return; + for (int j = 0; j < cols; j++) matrix[row, j] = array[j]; + } + public void SortAscending(int[] arr) + { + if (arr == null) return; + System.Array.Sort(arr); + } + public void SortDescending(int[] arr) + { + if (arr == null) return; + System.Array.Sort(arr); + System.Array.Reverse(arr); + } + public void SortMatrixRow(int[,] matrix, int row, Action sorter) + { + if (matrix == null || sorter == null) return; + if (row < 0 || row >= matrix.GetLength(0)) return; + int cols = matrix.GetLength(1); + int[] tmp = new int[cols]; + for (int j = 0; j < cols; j++) tmp[j] = matrix[row, j]; + sorter(tmp); + for (int j = 0; j < cols; j++) matrix[row, j] = tmp[j]; + } + public double CountZeroSum(int[][] array) + { + if (array == null) return 0; + int cnt = 0; + for (int i = 0; i < array.Length; i++) + { + int[] row = array[i] ?? System.Array.Empty(); + long s = 0; + for (int j = 0; j < row.Length; j++) s += row[j]; + if (s == 0) cnt++; + } + return cnt; + } + public double FindMedian(int[][] array) + { + if (array == null) return 0; + int total = 0; + for (int i = 0; i < array.Length; i++) total += (array[i]?.Length ?? 0); + if (total == 0) return 0; + int[] flat = new int[total]; + int k = 0; + for (int i = 0; i < array.Length; i++) + { + int[] row = array[i] ?? System.Array.Empty(); + for (int j = 0; j < row.Length; j++) flat[k++] = row[j]; + } + System.Array.Sort(flat); + if ((total & 1) == 1) return flat[total / 2]; + return (flat[total / 2 - 1] + flat[total / 2]) / 2.0; + } + public double CountLargeElements(int[][] array) + { + if (array == null) return 0; + long cnt = 0; + for (int i = 0; i < array.Length; i++) + { + int[] row = array[i] ?? System.Array.Empty(); + if (row.Length == 0) continue; + long sum = 0; + for (int j = 0; j < row.Length; j++) sum += row[j]; + double avg = (double)sum / row.Length; + for (int j = 0; j < row.Length; j++) if (row[j] > avg) cnt++; + } + return cnt; + } } -} \ No newline at end of file +} From 9e827b5cf62e3dfcadfd7b0967ac817dc2e41169 Mon Sep 17 00:00:00 2001 From: Ramy Berrekia Date: Tue, 16 Dec 2025 23:01:35 +0300 Subject: [PATCH 02/12] Create Shims.cs --- Lab6/Shims.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Lab6/Shims.cs diff --git a/Lab6/Shims.cs b/Lab6/Shims.cs new file mode 100644 index 00000000..53d64a00 --- /dev/null +++ b/Lab6/Shims.cs @@ -0,0 +1,13 @@ +namespace Lab6 +{ + public delegate void Sorting(int[] row); + + public class Finder { } + public class SortRowsStyle { } + public class ReplaceMaxElements { } + public class BikeRide { } + public class GetTriangle { } + public class SortRowsByMax { } + public class FindNegatives { } + public class MathInfo { } +} From dcee31284b5957e7c0b186fc08731ce4ffd79314 Mon Sep 17 00:00:00 2001 From: Ramy Berrekia Date: Tue, 16 Dec 2025 23:04:23 +0300 Subject: [PATCH 03/12] Update Green.cs --- Lab6/Green.cs | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/Lab6/Green.cs b/Lab6/Green.cs index bb9478c9..1663dd32 100644 --- a/Lab6/Green.cs +++ b/Lab6/Green.cs @@ -129,19 +129,19 @@ public void Task7(int[,] matrix, Sorting sort) } public int Task8(double[] A, double[] B) - { - int answer = 0; - - // code here - if (A == null || B == null || A.Length != 3 || B.Length != 3) return 0; - double a1 = GeronArea(A[0], A[1], A[2]); - double a2 = GeronArea(B[0], B[1], B[2]); - if (a1 == 0 && a2 == 0) answer = 0; - else answer = (a1 > a2) ? 1 : 2; - // end - - return answer; - } + { + int answer = 0; + + // code here + if (A == null || B == null || A.Length != 3 || B.Length != 3) return 0; + double a1 = GeronArea(A[0], A[1], A[2]); + double a2 = GeronArea(B[0], B[1], B[2]); + if (a1 == 0 && a2 == 0) return 0; + answer = (a1 >= a2) ? 1 : 2; // tie -> 1 + // end + + return answer; + } public void Task9(int[,] matrix, Action sorter) { @@ -376,3 +376,4 @@ public double CountLargeElements(int[][] array) } } } + From b7cedfdf4e66425281f8303834a21e957ea2d419 Mon Sep 17 00:00:00 2001 From: Ramy Berrekia Date: Tue, 16 Dec 2025 23:04:51 +0300 Subject: [PATCH 04/12] Update Shims.cs --- Lab6/Shims.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Lab6/Shims.cs b/Lab6/Shims.cs index 53d64a00..b5329485 100644 --- a/Lab6/Shims.cs +++ b/Lab6/Shims.cs @@ -1,6 +1,5 @@ namespace Lab6 { - public delegate void Sorting(int[] row); public class Finder { } public class SortRowsStyle { } From f0b7255043fbeb9e3da00e75b939a9fec7d915da Mon Sep 17 00:00:00 2001 From: Ramy Berrekia Date: Tue, 16 Dec 2025 23:09:09 +0300 Subject: [PATCH 05/12] Update Green.cs --- Lab6/Green.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Lab6/Green.cs b/Lab6/Green.cs index 1663dd32..6d54a884 100644 --- a/Lab6/Green.cs +++ b/Lab6/Green.cs @@ -3,9 +3,10 @@ namespace Lab6 { + public delegate void Sorting(int[] row); + public class Green { - public delegate void Sorting(int[] row); public void Task1(ref int[] A, ref int[] B) { @@ -377,3 +378,4 @@ public double CountLargeElements(int[][] array) } } + From b95646f097ce45c9bf1f962d41d449b2fe67ffd2 Mon Sep 17 00:00:00 2001 From: Ramy Berrekia Date: Wed, 17 Dec 2025 18:21:53 +0300 Subject: [PATCH 06/12] Delete Lab6/Blue.cs --- Lab6/Blue.cs | 94 ---------------------------------------------------- 1 file changed, 94 deletions(-) delete mode 100644 Lab6/Blue.cs diff --git a/Lab6/Blue.cs b/Lab6/Blue.cs deleted file mode 100644 index 067ce526..00000000 --- a/Lab6/Blue.cs +++ /dev/null @@ -1,94 +0,0 @@ -namespace Lab6 -{ - public class Blue - { - public void Task1(ref int[,] matrix) - { - - // code here - - // end - - } - public int Task2(int[,] A, int[,] B, int[,] C) - { - int answer = 0; // 1 - increasing 0 - no sequence -1 - decreasing - - // code here - - // end - - return answer; - } - public void Task3(ref int[,] matrix, Func method) - { - - // code here - - // end - - } - public void Task4(ref int[,] matrix) - { - - // code here - - // end - - } - public void Task5(ref int[,] matrix, Finder find) - { - - // code here - - // end - - } - public void Task6(int[,] matrix, SortRowsStyle sort) - { - - // code here - - // end - - } - public void Task7(int[,] matrix, ReplaceMaxElements transform) - { - - // code here - - // end - - } - public double[,] Task8(double a, double b, double h, Func getSum, Func getY) - { - double[,] answer = null; - - // code here - - // end - - return answer; - } - public int Task9(int[,] matrix, GetTriangle triangle) - { - int answer = 0; - - // code here - - // end - - return answer; - } - public bool Task10(int[][] array, Predicate func) - { - bool res = false; - - // code here - - // end - - return res; - } - } -} \ No newline at end of file From 483619e68a748a0b6dd7fef272cab75a581920c4 Mon Sep 17 00:00:00 2001 From: Ramy Berrekia Date: Wed, 17 Dec 2025 18:22:03 +0300 Subject: [PATCH 07/12] Delete Lab6/Purple.cs --- Lab6/Purple.cs | 96 -------------------------------------------------- 1 file changed, 96 deletions(-) delete mode 100644 Lab6/Purple.cs diff --git a/Lab6/Purple.cs b/Lab6/Purple.cs deleted file mode 100644 index 231c75b5..00000000 --- a/Lab6/Purple.cs +++ /dev/null @@ -1,96 +0,0 @@ -using System; -using System.Security.Cryptography; -using static System.Runtime.InteropServices.JavaScript.JSType; - -namespace Lab6 -{ - public class Purple - { - public void Task1(int[,] A, int[,] B) - { - - // code here - - // end - - } - public void Task2(ref int[,] A, int[,] B) - { - - // code here - - // end - - } - public void Task3(int[,] matrix) - { - - // code here - - // end - - } - public void Task4(int[,] A, int[,] B) - { - - // code here - - // end - - } - public void Task5(int[] matrix, Sorting sort) - { - - // code here - - // end - - } - public void Task6(int[,] matrix, SortRowsByMax sort) - { - - // code here - - // end - - } - public int[] Task7(int[,] matrix, FindNegatives find) - { - int[] negatives = null; - - // code here - - // end - - return negatives; - } - public int[,] Task8(int[,] matrix, MathInfo info) - { - int[,] answer = null; - - // code here - - // end - - return answer; - } - public int Task9(double a, double b, double h, Func func) - { - int answer = 0; - - // code here - - // end - - return answer; - } - public void Task10(int[][] array, Action func) - { - - // code here - - // end - - } - } -} \ No newline at end of file From 2fe8d3945351f8470bdb4d1da4cd00f65f4a84b5 Mon Sep 17 00:00:00 2001 From: Ramy Berrekia Date: Wed, 17 Dec 2025 18:22:15 +0300 Subject: [PATCH 08/12] Delete Lab6/White.cs --- Lab6/White.cs | 99 --------------------------------------------------- 1 file changed, 99 deletions(-) delete mode 100644 Lab6/White.cs diff --git a/Lab6/White.cs b/Lab6/White.cs deleted file mode 100644 index 0a2eed78..00000000 --- a/Lab6/White.cs +++ /dev/null @@ -1,99 +0,0 @@ -using System.Linq; -using System.Runtime.InteropServices; - -namespace Lab6 -{ - public class White - { - public void Task1(double[] A, double[] B) - { - - // code here - - // end - - } - public void Task2(int[,] A, int[,] B) - { - - // code here - - // end - - } - public int Task3(int[,] matrix) - { - int answer = 0; - - // code here - - // end - - return answer; - } - public void Task4(int[,] A, int[,] B) - { - - // code here - - // end - - } - public void Task5(int[,] A, int[,] B) - { - - // code here - - // end - - } - public void Task6(int[,] matrix, Sorting sort) - { - - // code here - - // end - - } - public long Task7(int n, int k) - { - long answer = 0; - - // code here - - // end - - return answer; - } - public double Task8(double v, double a, BikeRide ride) - { - double answer = 0; - - // code here - - // end - - return answer; - } - public int Task9(int[][] array) - { - int answer = 0; - - // code here - - // end - - return answer; - } - public int Task10(int[][] array, Func func) - { - int answer = 0; - - // code here - - // end - - return answer; - } - } -} \ No newline at end of file From c1ca762661e36567a55c0b76ff89e7e6963ab5ce Mon Sep 17 00:00:00 2001 From: Ramy Berrekia Date: Wed, 17 Dec 2025 18:23:22 +0300 Subject: [PATCH 09/12] Delete Lab6test/BlueTest.cs --- Lab6test/BlueTest.cs | 1203 ------------------------------------------ 1 file changed, 1203 deletions(-) delete mode 100644 Lab6test/BlueTest.cs diff --git a/Lab6test/BlueTest.cs b/Lab6test/BlueTest.cs deleted file mode 100644 index 460b0d7d..00000000 --- a/Lab6test/BlueTest.cs +++ /dev/null @@ -1,1203 +0,0 @@ -using System.Transactions; - -namespace Lab6test -{ - [TestClass] - public sealed class BlueTest - { - Lab6.Blue _main = new Lab6.Blue(); - const double E = 0.0001; - Data _data = new Data(); - - [TestMethod] - public void Test01() - { - // Arrange - var input = _data.GetMatrixes(); - var answer = new int[][,] { - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, 9, 10, 11}, - {9, 10, 11, 12, 13, 14, 15}, - {13, 14, 15, 16, 17, 18, 19}, - {0, 1, 2, 3, 4, 5, 6}, - }, - new int[,] { - {1}, - {5}, - {9}, - {13}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6}, - {5, 6, 7, 8, 9, 11}, - {0, 2, 3, 4, 5, 6}, - }, - new int[,] { - {1, 2, 4, 6}, - {5, -6, 7, 11}, - {-1, 4, -5, 6}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, -9, 10, 11}, - {9, 10, -11, -12, -13, -14, -15}, - {-13, -14, 15, 16, 17, 18, -19}, - }, - new int[,] { - {1, 2, 3}, - {0, -2, -3}, - }, - new int[,] { - {-9, -10, -11, -14, -15, 6}, - }, - new int[,] { - {1, 2, 3, 4, -5, -6, -7}, - {5, 11, -17, 11, -10, 6, 5}, - {-9, -10, -11, -14, -15, -16, 1}, - {-9, -10, -11, -14, -15, -6, -2}, - {-9, -10, -11, -14, -15, 6, 4}, - }, - new int[,] { - {1, 2, 3, 4, -5, -6, -7}, - {5, 11, -17, 11, -10, 6, 5}, - {-9, -10, -11, -14, -15, -16, 1}, - {-9, -10, -11, -14, 15, -6, -2}, - {-9, -10, -11, -14, -15, 6, 4}, - {5, 11, -17, 11, -10, 6, -5}, - {1, 1, -2, 3, -4, 0, 0}, - {0, -2, -3, -4, -5, 0, 5}, - }, - new int[,] { - {1, 2, 3, 4, -5}, - {-9, -10, -11, -14, -15}, - {-9, -10, -11, -14, -6}, - {0, -2, -3, -4, -5}, - } - }; - // Act - for (int i = 0; i < answer.Length; i++) - { - _main.Task1(ref input[i]); - } - // Assert - for (int i = 0; i < answer.Length; i++) - { - Assert.AreEqual(answer[i].GetLength(0), input[i].GetLength(0)); - for (int j = 0; j < answer[i].GetLength(0); j++) - { - Assert.AreEqual(answer[i].GetLength(1), input[i].GetLength(1)); - for (int k = 0; k < answer[i].GetLength(1); k++) - { - Assert.AreEqual(answer[i][j, k], input[i][j, k]); - } - } - } - } - [TestMethod] - public void Test02() - { - // Arrange - var inputA = _data.GetMatrixes(); - var inputB = _data.GetMatrixes(); - var inputC = _data.GetMatrixes(); - Array.Copy(inputA, 0, inputB, 1, 9); - Array.Reverse(inputC); - Array.Copy(inputC, 0, inputB, 1, 3); - var answer = new int[] { 0, 0, -1, -1, 0, 0, 1, 0, 0, 1 }; - var test = new int[answer.Length]; - // Act - for (int i = 0; i < answer.Length; i++) - { - test[i] = _main.Task2(inputA[i], inputB[i], inputC[i]); - } - // Assert - Assert.AreEqual(answer.Length, test.Length); - for (int i = 0; i < answer.Length; i++) - { - Assert.AreEqual(answer[i], test[i]); - } - } - [TestMethod] - public void Test03a() - { - // Arrange - var input = _data.GetMatrixes(); - var answer = new int[][,] { - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, 9, 10, 11}, - {9, 10, 11, 12, 13, 14, 15}, - {13, 14, 15, 16, 17, 18, 19}, - {0, 1, 2, 3, 4, 5, 6}, - }, - new int[,] { - {1}, - {5}, - {9}, - {13}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6}, - {5, 6, 7, 8, 9, 11}, - {0, 2, 3, 4, 5, 6}, - }, - new int[,] { - {1, 2, 4}, - {5, -6, 7}, - {-1, 4, -5}, - {1, 4, 5}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, -9, 10, 11}, - {9, 10, -11, -12, -13, -14, -15}, - {-13, -14, 15, 16, 17, 18, -19}, - }, - new int[,] { - {1, 2}, - {5, 11}, - {0, -2}, - }, - new int[,] { - {-9, -10, -11, -14, -15, 6}, - }, - new int[,] { - {1, 2, 3, 4, -5, -6, -7}, - {5, 11, -17, 11, -10, 6, 5}, - {-9, -10, -11, -14, -15, -16, 1}, - {-9, -10, -11, -14, -15, -6, -2}, - {-9, -10, -11, -14, -15, 6, 4}, - }, - new int[,] { - {1, 2, 3, 4, -5, -6, -7}, - {5, 11, -17, 11, -10, 6, 5}, - {-9, -10, -11, -14, -15, -16, 1}, - {-9, -10, -11, -14, 15, -6, -2}, - {-9, -10, -11, -14, -15, 6, 4}, - {5, 11, -17, 11, -10, 6, -5}, - {1, 1, -2, 3, -4, 0, 0}, - {0, -2, -3, -4, -5, 0, 5}, - }, - new int[,] { - {1, 2, 3, -5}, - {5, 11, -17, 7}, - {-9, -10, -11, -15}, - {-9, -10, -11, -6}, - {0, -2, -3, -5}, - } - }; - // Act - for (int i = 0; i < answer.Length; i++) - { - _main.Task3(ref input[i], _main.FindUpperColIndex); - } - // Assert - for (int i = 0; i < answer.Length; i++) - { - Assert.AreEqual(answer[i].GetLength(0), input[i].GetLength(0)); - for (int j = 0; j < answer[i].GetLength(0); j++) - { - Assert.AreEqual(answer[i].GetLength(1), input[i].GetLength(1)); - for (int k = 0; k < answer[i].GetLength(1); k++) - { - Assert.AreEqual(answer[i][j, k], input[i][j, k]); - } - } - } - } - [TestMethod] - public void Test03b() - { - // Arrange - var input = _data.GetMatrixes(); - var answer = new int[][,] { - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, 9, 10, 11}, - {9, 10, 11, 12, 13, 14, 15}, - {13, 14, 15, 16, 17, 18, 19}, - {0, 1, 2, 3, 4, 5, 6}, - }, - new int[,] { - {1}, - {5}, - {9}, - {13}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6}, - {5, 6, 7, 8, 9, 11}, - {0, 2, 3, 4, 5, 6}, - }, - new int[,] { - {1, 2, 4}, - {5, -6, 7}, - {-1, 4, -5}, - {1, 4, 5}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, -9, 10, 11}, - {9, 10, -11, -12, -13, -14, -15}, - {-13, -14, 15, 16, 17, 18, -19}, - }, - new int[,] { - {1, 3}, - {5, -17}, - {0, -3}, - }, - new int[,] { - {-9, -10, -11, -14, -15, 6}, - }, - new int[,] { - {1, 2, 3, 4, -5, -6, -7}, - {5, 11, -17, 11, -10, 6, 5}, - {-9, -10, -11, -14, -15, -16, 1}, - {-9, -10, -11, -14, -15, -6, -2}, - {-9, -10, -11, -14, -15, 6, 4}, - }, - new int[,] { - {1, 2, 3, 4, -5, -6, -7}, - {5, 11, -17, 11, -10, 6, 5}, - {-9, -10, -11, -14, -15, -16, 1}, - {-9, -10, -11, -14, 15, -6, -2}, - {-9, -10, -11, -14, -15, 6, 4}, - {5, 11, -17, 11, -10, 6, -5}, - {1, 1, -2, 3, -4, 0, 0}, - {0, -2, -3, -4, -5, 0, 5}, - }, - new int[,] { - {1, 3, 4, -5}, - {5, -17, 11, 7}, - {-9, -11, -14, -15}, - {-9, -11, -14, -6}, - {0, -3, -4, -5}, - } - }; - // Act - for (int i = 0; i < answer.Length; i++) - { - _main.Task3(ref input[i], _main.FindLowerColIndex); - } - // Assert - for (int i = 0; i < answer.Length; i++) - { - Assert.AreEqual(answer[i].GetLength(0), input[i].GetLength(0)); - for (int j = 0; j < answer[i].GetLength(0); j++) - { - Assert.AreEqual(answer[i].GetLength(1), input[i].GetLength(1)); - for (int k = 0; k < answer[i].GetLength(1); k++) - { - Assert.AreEqual(answer[i][j, k], input[i][j, k]); - } - } - } - } - [TestMethod] - public void Test04() - { - // Arrange - var input = _data.GetMatrixes(); - var answer = new int[][,] { - new int[,] { - {1}, - {5}, - {9}, - {13}, - {0}, - }, - new int[,] { - {}, - {}, - {}, - {}, - }, - new int[,] { - {1}, - {5}, - {0}, - }, - new int[,] { - {}, - {}, - {}, - {}, - }, - new int[,] { - {}, - {}, - {}, - {}, - }, - new int[,] { - {1}, - {5}, - {0}, - }, - new int[,] { - {}, - }, - new int[,] { - {}, - {}, - {}, - {}, - {}, - }, - new int[,] { - {1, -6, -7}, - {5, 6, 5}, - {-9, -16, 1}, - {-9, -6, -2}, - {-9, 6, 4}, - {5, 6, -5}, - {1, 0, 0}, - {0, 0, 5}, - }, - new int[,] { - {1}, - {5}, - {-9}, - {-9}, - {0}, - } - }; - // Act - for (int i = 0; i < answer.Length; i++) - { - _main.Task4(ref input[i]); - } - // Assert - for (int i = 0; i < answer.Length; i++) - { - Assert.AreEqual(answer[i].GetLength(0), input[i].GetLength(0)); - for (int j = 0; j < answer[i].GetLength(0); j++) - { - Assert.AreEqual(answer[i].GetLength(1), input[i].GetLength(1)); - for (int k = 0; k < answer[i].GetLength(1); k++) - { - Assert.AreEqual(answer[i][j, k], input[i][j, k]); - } - } - } - } - [TestMethod] - public void Test05A() - { - // Arrange - var input = _data.GetMatrixes(); - var answer = new int[][,] { - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, 9, 10, 11}, - {9, 10, 11, 12, 13, 14, 15}, - {0, 1, 2, 3, 4, 5, 6}, - }, - new int[,] { - {1}, - {5}, - {9}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6}, - {0, 2, 3, 4, 5, 6}, - }, - new int[,] { - {1, 2, 4, 6}, - {-1, 4, -5, 6}, - {1, 4, 5, 6}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, -9, 10, 11}, - {9, 10, -11, -12, -13, -14, -15}, - }, - new int[,] { - {1, 2, 3}, - {0, -2, -3}, - }, - new int[,] { - }, - new int[,] { - {1, 2, 3, 4, -5, -6, -7}, - {-9, -10, -11, -14, -15, -16, 1}, - {-9, -10, -11, -14, -15, -6, -2}, - {-9, -10, -11, -14, -15, 6, 4}, - }, - new int[,] { - {1, 2, 3, 4, -5, -6, -7}, - {5, 11, -17, 11, -10, 6, 5}, - {-9, -10, -11, -14, -15, -16, 1}, - {-9, -10, -11, -14, -15, 6, 4}, - {5, 11, -17, 11, -10, 6, -5}, - {1, 1, -2, 3, -4, 0, 0}, - {0, -2, -3, -4, -5, 0, 5}, - }, - new int[,] { - {1, 2, 3, 4, -5}, - {-9, -10, -11, -14, -15}, - {-9, -10, -11, -14, -6}, - {0, -2, -3, -4, -5}, - } - }; - // Act - for (int i = 0; i < answer.Length; i++) - { - _main.Task5(ref input[i], _main.FindMax); - } - // Assert - for (int i = 0; i < answer.Length; i++) - { - Assert.AreEqual(answer[i].GetLength(0), input[i].GetLength(0)); - for (int j = 0; j < answer[i].GetLength(0); j++) - { - Assert.AreEqual(answer[i].GetLength(1), input[i].GetLength(1)); - for (int k = 0; k < answer[i].GetLength(1); k++) - { - Assert.AreEqual(answer[i][j, k], input[i][j, k]); - } - } - } - } - [TestMethod] - public void Test05B() - { - // Arrange - var input = _data.GetMatrixes(); - var answer = new int[][,] { - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, 9, 10, 11}, - {9, 10, 11, 12, 13, 14, 15}, - {13, 14, 15, 16, 17, 18, 19}, - }, - new int[,] { - {5}, - {9}, - {13}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6}, - {5, 6, 7, 8, 9, 11}, - }, - new int[,] { - {1, 2, 4, 6}, - {-1, 4, -5, 6}, - {1, 4, 5, 6}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, -9, 10, 11}, - {9, 10, -11, -12, -13, -14, -15}, - }, - new int[,] { - {1, 2, 3}, - {0, -2, -3}, - }, - new int[,] { - }, - new int[,] { - {1, 2, 3, 4, -5, -6, -7}, - {-9, -10, -11, -14, -15, -16, 1}, - {-9, -10, -11, -14, -15, -6, -2}, - {-9, -10, -11, -14, -15, 6, 4}, - }, - new int[,] { - {1, 2, 3, 4, -5, -6, -7}, - {-9, -10, -11, -14, -15, -16, 1}, - {-9, -10, -11, -14, 15, -6, -2}, - {-9, -10, -11, -14, -15, 6, 4}, - {1, 1, -2, 3, -4, 0, 0}, - {0, -2, -3, -4, -5, 0, 5}, - }, - new int[,] { - {1, 2, 3, 4, -5}, - {-9, -10, -11, -14, -15}, - {-9, -10, -11, -14, -6}, - {0, -2, -3, -4, -5}, - } - }; - // Act - for (int i = 0; i < answer.Length; i++) - { - _main.Task5(ref input[i], _main.FindMin); - } - // Assert - for (int i = 0; i < answer.Length; i++) - { - Assert.AreEqual(answer[i].GetLength(0), input[i].GetLength(0)); - for (int j = 0; j < answer[i].GetLength(0); j++) - { - Assert.AreEqual(answer[i].GetLength(1), input[i].GetLength(1)); - for (int k = 0; k < answer[i].GetLength(1); k++) - { - Assert.AreEqual(answer[i][j, k], input[i][j, k]); - } - } - } - } - [TestMethod] - public void Test06A() - { - // Arrange - var input = _data.GetMatrixes(); - var answer = new int[][,] { - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, 9, 10, 11}, - {9, 10, 11, 12, 13, 14, 15}, - {13, 14, 15, 16, 17, 18, 19}, - {0, 1, 2, 3, 4, 5, 6}, - }, - new int[,] { - {1}, - {5}, - {9}, - {13}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6}, - {5, 6, 7, 8, 9, 11}, - {0, 2, 3, 4, 5, 6}, - }, - new int[,] { - {1, 2, 4, 6}, - {5, -6, 7, 11}, - {-1, 4, -5, 6}, - {1, 4, 5, 6}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, -9, 10, 11}, - {9, 10, -11, -12, -13, -14, -15}, - {-19, -14, -13, 15, 16, 17, 18}, - }, - new int[,] { - {1, 2, 3}, - {5, 11, -17}, - {0, -2, -3}, - }, - new int[,] { - {-15, -14, -11, -10, -9, 6}, - }, - new int[,] { - {-7, -6, -5, 1, 2, 3, 4}, - {5, 11, -17, 11, -10, 6, 5}, - {-9, -10, -11, -14, -15, -16, 1}, - {-15, -14, -11, -10, -9, -6, -2}, - {-9, -10, -11, -14, -15, 6, 4}, - }, - new int[,] { - {-7, -6, -5, 1, 2, 3, 4}, - {5, 11, -17, 11, -10, 6, 5}, - {-9, -10, -11, -14, -15, -16, 1}, - {-14, -11, -10, -9, -6, -2, 15}, - {-9, -10, -11, -14, -15, 6, 4}, - {5, 11, -17, 11, -10, 6, -5}, - {-4, -2, 0, 0, 1, 1, 3}, - {0, -2, -3, -4, -5, 0, 5}, - }, - new int[,] { - {-5, 1, 2, 3, 4}, - {5, 11, -17, 11, 7}, - {-9, -10, -11, -14, -15}, - {-14, -11, -10, -9, -6}, - {0, -2, -3, -4, -5}, - } - }; - // Act - for (int i = 0; i < answer.Length; i++) - { - _main.Task6(input[i], _main.SortRowAscending); - } - // Assert - for (int i = 0; i < answer.Length; i++) - { - Assert.AreEqual(answer[i].GetLength(0), input[i].GetLength(0)); - for (int j = 0; j < answer[i].GetLength(0); j++) - { - Assert.AreEqual(answer[i].GetLength(1), input[i].GetLength(1)); - for (int k = 0; k < answer[i].GetLength(1); k++) - { - Assert.AreEqual(answer[i][j, k], input[i][j, k]); - } - } - } - } - - [TestMethod] - public void Test06B() - { - // Arrange - var input = _data.GetMatrixes(); - var answer = new int[][,] { - new int[,] { - {7, 6, 5, 4, 3, 2, 1}, - {5, 6, 7, 8, 9, 10, 11}, - {9, 10, 11, 12, 13, 14, 15}, - {19, 18, 17, 16, 15, 14, 13}, - {0, 1, 2, 3, 4, 5, 6}, - }, - new int[,] { - {1}, - {5}, - {9}, - {13}, - }, - new int[,] { - {6, 5, 4, 3, 2, 1}, - {5, 6, 7, 8, 9, 11}, - {0, 2, 3, 4, 5, 6}, - }, - new int[,] { - {6, 4, 2, 1}, - {5, -6, 7, 11}, - {-1, 4, -5, 6}, - {6, 5, 4, 1}, - }, - new int[,] { - {7, 6, 5, 4, 3, 2, 1}, - {5, 6, 7, 8, -9, 10, 11}, - {9, 10, -11, -12, -13, -14, -15}, - {18, 17, 16, 15, -13, -14, -19}, - }, - new int[,] { - {3, 2, 1}, - {5, 11, -17}, - {0, -2, -3}, - }, - new int[,] { - {6, -9, -10, -11, -14, -15}, - }, - new int[,] { - {4, 3, 2, 1, -5, -6, -7}, - {5, 11, -17, 11, -10, 6, 5}, - {-9, -10, -11, -14, -15, -16, 1}, - {-2, -6, -9, -10, -11, -14, -15}, - {-9, -10, -11, -14, -15, 6, 4}, - }, - new int[,] { - {4, 3, 2, 1, -5, -6, -7}, - {5, 11, -17, 11, -10, 6, 5}, - {-9, -10, -11, -14, -15, -16, 1}, - {15, -2, -6, -9, -10, -11, -14}, - {-9, -10, -11, -14, -15, 6, 4}, - {5, 11, -17, 11, -10, 6, -5}, - {3, 1, 1, 0, 0, -2, -4}, - {0, -2, -3, -4, -5, 0, 5}, - }, - new int[,] { - {4, 3, 2, 1, -5}, - {5, 11, -17, 11, 7}, - {-9, -10, -11, -14, -15}, - {-6, -9, -10, -11, -14}, - {0, -2, -3, -4, -5}, - } - }; - // Act - for (int i = 0; i < answer.Length; i++) - { - _main.Task6(input[i], _main.SortRowDescending); - } - // Assert - for (int i = 0; i < answer.Length; i++) - { - Assert.AreEqual(answer[i].GetLength(0), input[i].GetLength(0)); - for (int j = 0; j < answer[i].GetLength(0); j++) - { - Assert.AreEqual(answer[i].GetLength(1), input[i].GetLength(1)); - for (int k = 0; k < answer[i].GetLength(1); k++) - { - Assert.AreEqual(answer[i][j, k], input[i][j, k]); - } - } - } - } - [TestMethod] - public void Test07A() - { - // Arrange - var input = _data.GetMatrixes(); - var answer = new int[][,] { - new int[,] { - {1, 2, 3, 4, 5, 6, 0}, - {5, 6, 7, 8, 9, 10, 0}, - {9, 10, 11, 12, 13, 14, 0}, - {13, 14, 15, 16, 17, 18, 0}, - {0, 1, 2, 3, 4, 5, 0}, - }, - new int[,] { - {0}, - {0}, - {0}, - {0}, - }, - new int[,] { - {1, 2, 3, 4, 5, 0}, - {5, 6, 7, 8, 9, 0}, - {0, 2, 3, 4, 5, 0}, - }, - new int[,] { - {1, 2, 4, 0}, - {5, -6, 7, 0}, - {-1, 4, -5, 0}, - {1, 4, 5, 0}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6, 0}, - {5, 6, 7, 8, -9, 10, 0}, - {9, 0, -11, -12, -13, -14, -15}, - {-13, -14, 15, 16, 17, 0, -19}, - }, - new int[,] { - {1, 2, 0}, - {5, 0, -17}, - {0, -2, -3}, - }, - new int[,] { - {-9, -10, -11, -14, -15, 0}, - }, - new int[,] { - {1, 2, 3, 0, -5, -6, -7}, - {5, 0, -17, 0, -10, 6, 5}, - {-9, -10, -11, -14, -15, -16, 0}, - {-9, -10, -11, -14, -15, -6, 0}, - {-9, -10, -11, -14, -15, 0, 4}, - }, - new int[,] { - {1, 2, 3, 0, -5, -6, -7}, - {5, 0, -17, 0, -10, 6, 5}, - {-9, -10, -11, -14, -15, -16, 0}, - {-9, -10, -11, -14, 0, -6, -2}, - {-9, -10, -11, -14, -15, 0, 4}, - {5, 0, -17, 0, -10, 6, -5}, - {1, 1, -2, 0, -4, 0, 0}, - {0, -2, -3, -4, -5, 0, 0}, - }, - new int[,] { - {1, 2, 3, 0, -5}, - {5, 0, -17, 0, 7}, - {0, -10, -11, -14, -15}, - {-9, -10, -11, -14, 0}, - {0, -2, -3, -4, -5}, - } - }; - // Act - for (int i = 0; i < answer.Length; i++) - { - _main.Task7(input[i], _main.ReplaceByZero); - } - // Assert - for (int i = 0; i < answer.Length; i++) - { - Assert.AreEqual(answer[i].GetLength(0), input[i].GetLength(0)); - for (int j = 0; j < answer[i].GetLength(0); j++) - { - Assert.AreEqual(answer[i].GetLength(1), input[i].GetLength(1)); - for (int k = 0; k < answer[i].GetLength(1); k++) - { - Assert.AreEqual(answer[i][j, k], input[i][j, k]); - } - } - } - } - [TestMethod] - public void Test07B() - { - // Arrange - var input = _data.GetMatrixes(); - var answer = new int[][,] { - new int[,] { - {1, 2, 3, 4, 5, 6, 49}, - {5, 6, 7, 8, 9, 10, 77}, - {9, 10, 11, 12, 13, 14, 105}, - {13, 14, 15, 16, 17, 18, 133}, - {0, 1, 2, 3, 4, 5, 42}, - }, - new int[,] { - {1}, - {5}, - {9}, - {13}, - }, - new int[,] { - {1, 2, 3, 4, 5, 36}, - {5, 6, 7, 8, 9, 66}, - {0, 2, 3, 4, 5, 36}, - }, - new int[,] { - {1, 2, 4, 24}, - {5, -6, 7, 44}, - {-1, 4, -5, 24}, - {1, 4, 5, 24}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6, 49}, - {5, 6, 7, 8, -9, 10, 77}, - {9, 20, -11, -12, -13, -14, -15}, - {-13, -14, 15, 16, 17, 108, -19}, - }, - new int[,] { - {1, 2, 9}, - {5, 22, -17}, - {0, -2, -3}, - }, - new int[,] { - {-9, -10, -11, -14, -15, 36}, - }, - new int[,] { - {1, 2, 3, 16, -5, -6, -7}, - {5, 22, -17, 44, -10, 6, 5}, - {-9, -10, -11, -14, -15, -16, 7}, - {-9, -10, -11, -14, -15, -6, -14}, - {-9, -10, -11, -14, -15, 36, 4}, - }, - new int[,] { - {1, 2, 3, 16, -5, -6, -7}, - {5, 22, -17, 44, -10, 6, 5}, - {-9, -10, -11, -14, -15, -16, 7}, - {-9, -10, -11, -14, 75, -6, -2}, - {-9, -10, -11, -14, -15, 36, 4}, - {5, 22, -17, 44, -10, 6, -5}, - {1, 1, -2, 12, -4, 0, 0}, - {0, -2, -3, -4, -5, 0, 35}, - }, - new int[,] { - {1, 2, 3, 16, -5}, - {5, 22, -17, 44, 7}, - {-9, -10, -11, -14, -15}, - {-9, -10, -11, -14, -30}, - {0, -2, -3, -4, -5}, - } - }; - // Act - for (int i = 0; i < answer.Length; i++) - { - _main.Task7(input[i], _main.MultiplyByColumn); - } - // Assert - for (int i = 0; i < answer.Length; i++) - { - Assert.AreEqual(answer[i].GetLength(0), input[i].GetLength(0)); - for (int j = 0; j < answer[i].GetLength(0); j++) - { - Assert.AreEqual(answer[i].GetLength(1), input[i].GetLength(1)); - for (int k = 0; k < answer[i].GetLength(1); k++) - { - Assert.AreEqual(answer[i][j, k], input[i][j, k]); - } - } - } - } - [TestMethod] - public void Test08A() - { - // Arrange - var inputA = 0.1; - var inputB = 1; - var inputH = 0.1; - var answer = new double[,] { - {2.6912681270017194, 2.691268139166703}, - {2.6122212502032887, 2.6122204929844544}, - {2.4868568953361008, 2.486856868603152}, - {2.323884253225943, 2.3238842457941966}, - {2.1339300133437806, 2.133930111437405}, - {1.9283342127279457, 1.9283342378052784}, - {1.7179999583568928, 1.7179999609519054}, - {1.5124670271786733, 1.5124670047163078}, - {1.3193029843812667, 1.3193027107322826}, - {1.1438356417724056, 1.1438356437916406}, - }; - var test = new double[answer.GetLength(0), answer.GetLength(1)]; - // Act - test = _main.Task8(inputA, inputB, inputH, _main.SumA, _main.YA); - // Assert - Assert.AreEqual(answer.GetLength(0), test.GetLength(0)); - Assert.AreEqual(answer.GetLength(1), test.GetLength(1)); - for (int i = 0; i < answer.GetLength(0); i++) - { - for (int j = 0; j < answer.GetLength(1); j++) - { - Assert.AreEqual(answer[i, j], test[i, j], E); - } - } - } - [TestMethod] - public void Test08B() - { - // Arrange - var inputA = Math.PI / 5; - var inputB = Math.PI; - var inputH = Math.PI / 25; - var answer = new double[,] { - {-7.303507257791954, -7.303507256806125}, - {-7.260083616438886, -7.260080997441332}, - {-7.20875508832593, -7.208759054555667}, - {-7.149545913780194, -7.149541428149131}, - {-7.082422850960618, -7.082428118221723}, - {-7.007419743934666, -7.0074191247734445}, - {-6.924507777616338, -6.9245144478042935}, - {-6.833707144188682, -6.833714087314272}, - {-6.735009114927305, -6.735018043303378}, - {-6.628434910121376, -6.6284263157716135}, - {-6.51393629032441, -6.513938904718977}, - {-6.391544374889424, -6.391555810145468}, - {-6.261289902367042, -6.261277032051089}, - {-6.123087221829428, -6.1231025704358375}, - {-5.977012101846995, -5.977032425299715}, - {-5.823071802317092, -5.823066596642721}, - {-5.661174273430562, -5.661205084464855}, - {-5.49140693658761, -5.491447888766118}, - {-5.313734462977021, -5.313795009546508}, - {-5.128131509726421, -5.128246446806029}, - {-4.935801700711345, -4.934802200544677}, - }; - var test = new double[answer.GetLength(0), answer.GetLength(1)]; - // Act - test = _main.Task8(inputA, inputB, inputH, _main.SumB, _main.YB); - // Assert - Assert.AreEqual(answer.GetLength(0), test.GetLength(0)); - Assert.AreEqual(answer.GetLength(1), test.GetLength(1)); - for (int i = 0; i < answer.GetLength(0); i++) - { - for (int j = 0; j < answer.GetLength(1); j++) - { - Assert.AreEqual(answer[i, j], test[i, j], E); - } - } - } - [TestMethod] - public void Test09A() - { - // Arrange - var input = _data.GetMatrixes(); - var answer = new int[] { 0, 0, 0, 360, 0, 433, 0, 0, 0, 1434 }; - var test = new int[answer.Length]; - // Act - for (int i = 0; i < answer.Length; i++) - { - test[i] = _main.Task9(input[i], _main.GetUpperTriangle); - } - // Assert - Assert.AreEqual(answer.Length, test.Length); - for (int i = 0; i < answer.Length; i++) - { - Assert.AreEqual(answer[i], test[i]); - } - } - [TestMethod] - public void Test09B() - { - // Arrange - var input = _data.GetMatrixes(); - var answer = new int[] { 0, 0, 0, 182, 0, 160, 0, 0, 0, 1001 }; - var test = new int[answer.Length]; - // Act - for (int i = 0; i < answer.Length; i++) - { - test[i] = _main.Task9(input[i], _main.GetLowerTriangle); - } - // Assert - Assert.AreEqual(answer.Length, test.Length); - for (int i = 0; i < answer.Length; i++) - { - Assert.AreEqual(answer[i], test[i]); - } - } - [TestMethod] - public void Test10A() - { - // Arrange - var input = _data.GetArrayArrays(); - var answer = new bool[5] { false, true, true, true, false }; - var test = new bool[answer.Length]; - // Act - for (int i = 0; i < answer.Length; i++) - { - test[i] = _main.Task10(input[i], _main.CheckTransformAbility); - } - // Assert - Assert.AreEqual(answer.Length, test.Length); - for (int i = 0; i < answer.Length; i++) - { - Assert.AreEqual(answer[i], test[i]); - } - } - [TestMethod] - public void Test10B() - { - // Arrange - var input = _data.GetArrayArrays(); - var answer = new bool[5] { false, false, true, false, false }; - var test = new bool[answer.Length]; - // Act - for (int i = 0; i < answer.Length; i++) - { - test[i] = _main.Task10(input[i], _main.CheckSumOrder); - } - // Assert - Assert.AreEqual(answer.Length, test.Length); - for (int i = 0; i < answer.Length; i++) - { - Assert.AreEqual(answer[i], test[i]); - } - } - [TestMethod] - public void Test10C() - { - // Arrange - var input = _data.GetArrayArrays(); - var answer = new bool[5] { true, true, false, true, false }; - var test = new bool[answer.Length]; - // Act - for (int i = 0; i < answer.Length; i++) - { - test[i] = _main.Task10(input[i], _main.CheckArraysOrder); - } - // Assert - Assert.AreEqual(answer.Length, test.Length); - for (int i = 0; i < answer.Length; i++) - { - Assert.AreEqual(answer[i], test[i]); - } - } - [TestMethod] - public void Test_FindDiagonalMaxIndex() - { - var matrix = new int[,] { { 1, 2 }, { 3, 4 } }; - int result = _main.FindDiagonalMaxIndex(matrix); - Assert.AreEqual(1, result); - } - - [TestMethod] - public void Test_RemoveRow() - { - var matrix = new int[,] { { 1, 2 }, { 3, 4 }, { 5, 6 } }; - _main.RemoveRow(ref matrix, 1); - var expected = new int[,] { { 1, 2 }, { 5, 6 } }; - CollectionAssert.AreEqual(expected.Cast().ToArray(), matrix.Cast().ToArray()); - } - - [TestMethod] - public void Test_GetAverageExceptEdges() - { - var matrix = new int[,] { { 1, 2, 3 }, { 4, 5, 6 } }; - double avg = _main.GetAverageExceptEdges(matrix); - // Убираем 1 и 6 → остаются [2,3,4,5], среднее = 3.5 - Assert.AreEqual(3.5, avg, E); - } - - [TestMethod] - public void Test_FindMaxMin() - { - var matrix = new int[,] { { -2, 10 }, { -5, 0 } }; - Assert.AreEqual(10, _main.FindMax(matrix, out int i, out int j)); - Assert.AreEqual(0, i); - Assert.AreEqual(1, j); - Assert.AreEqual(-5, _main.FindMin(matrix, out i, out j)); - Assert.AreEqual(1, i); - Assert.AreEqual(0, j); - } - - [TestMethod] - public void Test_RemoveColumn() - { - var matrix = new int[,] { { 1, 2, 3 }, { 4, 5, 6 } }; - _main.RemoveColumn(ref matrix, 1); - var expected = new int[,] { { 1, 3 }, { 4, 6 } }; - CollectionAssert.AreEqual(expected.Cast().ToArray(), matrix.Cast().ToArray()); - } - - [TestMethod] - public void Test_CheckZerosInColumn() - { - var matrix = new int[,] { { 1, 0 }, { 3, 4 } }; - Assert.IsTrue(_main.CheckZerosInColumn(matrix, 1)); - Assert.IsFalse(_main.CheckZerosInColumn(matrix, 0)); - } - - [TestMethod] - public void Test_FindMaxMinWithOut() - { - var matrix = new int[,] { { 1, 2 }, { 3, 4 } }; - int row, col; - Assert.AreEqual(4, _main.FindMax(matrix, out row, out col)); - Assert.AreEqual(1, _main.FindMin(matrix, out row, out col)); - } - - [TestMethod] - public void Test_SortRowAscendingDescending() - { - var matrix = new int[,] { { 3, 1, 2 }, - { 8, 2, 54 } }; - _main.SortRowAscending(matrix, 0); - CollectionAssert.AreEqual(new int[] { 1, 2, 3, 8, 2, 54 }, matrix.Cast().ToArray()); - - matrix = new int[,] { { 3, 1, 2 }, - { 8, 2, 54 } }; - _main.SortRowDescending(matrix, 0); - CollectionAssert.AreEqual(new int[] { 3, 2, 1, 8, 2, 54 }, matrix.Cast().ToArray()); - } - - [TestMethod] - public void Test_FindMaxInRowAndReplace() - { - var matrix = new int[,] { { 1, 3, 3 } }; - int max = _main.FindMaxInRow(matrix, 0); - Assert.AreEqual(3, max); - - _main.ReplaceByZero(matrix, 0, max); - CollectionAssert.AreEqual(new int[] { 1, 0, 0 }, matrix.Cast().ToArray()); - } - - [TestMethod] - public void Test_MultiplyByColumn() - { - var matrix = new int[,] { { 2, 5, 5 } }; - _main.MultiplyByColumn(matrix, 0, 5); - // 5*2 и 5*3 → 10, 15 - CollectionAssert.AreEqual(new int[] { 2, 10, 15 }, matrix.Cast().ToArray()); - } - - [TestMethod] - public void Test_Sum_Simple() - { - var arr = new int[] { 1, 2, 3 }; - int result = _main.Sum(arr); - // 1²+2²+3²=14 - Assert.AreEqual(14, result); - } - - [TestMethod] - public void Test_GetUpperAndLowerTriangle() - { - var matrix = new int[,] { { 1, 2 }, { 3, 4 } }; - var upper = _main.GetUpperTriangle(matrix); - var lower = _main.GetLowerTriangle(matrix); - CollectionAssert.AreEqual(new int[] { 1, 2, 4 }, upper); - CollectionAssert.AreEqual(new int[] { 1, 3, 4 }, lower); - } - - [TestMethod] - public void Test_CheckSumOrder() - { - var array = new int[][] { new[] { 1, 2 }, new[] { 3, 4 }, new[] { 5, 6 } }; - Assert.IsTrue(_main.CheckSumOrder(array)); // возрастающая сумма - } - - [TestMethod] - public void Test_CheckArraysOrder() - { - var array = new int[][] { new[] { 1, 2, 3 }, new[] { 3, 1 } }; - Assert.IsTrue(_main.CheckArraysOrder(array)); // один из массивов упорядочен - } - - [TestMethod] - public void Test_CheckTransformAbility() - { - var array = new int[][] { new[] { 1, 2, 3 }, new[] { 4, 5 }, new[] { 6 } }; - Assert.IsTrue(_main.CheckTransformAbility(array)); - } - } -} From 27fa30d5f10fab56e35a75496b93570f2cb79d68 Mon Sep 17 00:00:00 2001 From: Ramy Berrekia Date: Wed, 17 Dec 2025 18:23:31 +0300 Subject: [PATCH 10/12] Delete Lab6test/PurpleTest.cs --- Lab6test/PurpleTest.cs | 2017 ---------------------------------------- 1 file changed, 2017 deletions(-) delete mode 100644 Lab6test/PurpleTest.cs diff --git a/Lab6test/PurpleTest.cs b/Lab6test/PurpleTest.cs deleted file mode 100644 index cf3575be..00000000 --- a/Lab6test/PurpleTest.cs +++ /dev/null @@ -1,2017 +0,0 @@ -namespace Lab6test -{ - [TestClass] - public sealed class PurpleTest - { - Lab6.Purple _main = new Lab6.Purple(); - const double E = 0.0001; - Data _data = new Data(); - - [TestMethod] - public void Test01() - { - // Arrange - var inputA = new int[][,] { - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, 9, 10, 11}, - {9, 10, 11, 12, 13, 14, 15}, - {13, 14, 15, 16, 17, 18, 19}, - {0, 1, 2, 3, 4, 5, 6}, - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, 9, 10, 11}, - }, - new int[,] { - {1, 2, 4, 6}, - {5, -6, 7, 11}, - {-1, 4, -5, 6}, - {1, 4, 5, 6}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6}, - {5, 6, 7, 8, 9, 11}, - {0, 2, 3, 4, 5, 6}, - {9, 10, 11, 12, 13, 14}, - {13, 14, 15, 16, 17, 19}, - {0, 1, 2, 3, 4, 5}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, 9, 10, 11}, - {9, 10, 11, 12, 13, 14, 15}, - {13, 14, 15, 16, 17, 18, 19}, - {5, 6, 7, 8, -9, 10, 11}, - {9, 10, -11, -12, -13, -14, -15}, - {-13, -14, 15, 16, 17, 18, -19}, - }, - new int[,] { - {1, 2, 3}, - {5, 11, -17}, - {0, -2, -3}, - }, - new int[,] { - {1, 2, 3, 4, -5}, - {5, 11, -17, 11, 7}, - {-9, -10, -11, -14, -15}, - {-9, -10, -11, -14, -6}, - {0, -2, -3, -4, -5}, - }, - new int[,] { - {1, 2, 3, 4, -5, -6, -7}, - {5, 11, -17, 11, -10, 6, 5}, - {5, 6, 7, 8, 9, 10, 11}, - {-9, -10, -11, -14, -15, -16, 1}, - {-9, -10, -11, -14, -15, -6, -2}, - {5, 6, 7, 8, 9, 10, 11}, - {-9, -10, -11, -14, -15, 6, 4}, - }, - new int[,] { - {-9, -10, -11, -14, -15, 6}, - {5, 6, 7, 8, 9, 11}, - {0, 2, 3, 4, 5, 6}, - {9, 10, 11, 12, 13, 14}, - {13, 14, 15, 16, 17, 19}, - {0, 1, 2, 3, 4, 5}, - }, - new int[,] { - {1, 2, 4, 6}, - {5, -6, 7, 11}, - {-1, 4, -5, 6}, - {1, 4, 5, 6}, - }, - new int[,] { - {1, 2, 3, 4, -5, -6, -7}, - {5, 11, -17, 11, -10, 6, 5}, - {-9, -10, -11, -14, -15, -16, 1}, - {-9, -10, -11, -14, 15, -6, -2}, - {-9, -10, -11, -14, -15, 6, 4}, - {5, 11, -17, 11, -10, 6, -5}, - {0, -2, -3, -4, -5, 0, 5}, - } - }; - var inputB = new int[][,] { - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, 9, 10, 11}, - {9, 10, 11, 12, 13, 14, 15}, - {13, 14, 15, 16, 17, 18, 19}, - {0, 1, 2, 3, 4, 5, 6}, - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, 9, 10, 11}, - }, - new int[,] { - {1, 2, 4, 6}, - {5, -6, 7, 11}, - {-1, 4, -5, 6}, - {1, 4, 5, 6}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6}, - {5, 6, 7, 8, 9, 11}, - {0, 2, 3, 4, 5, 6}, - {9, 10, 11, 12, 13, 14}, - {13, 14, 15, 16, 17, 19}, - {0, 1, 2, 3, 4, 5}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, 9, 10, 11}, - {9, 10, 11, 12, 13, 14, 15}, - {13, 14, 15, 16, 17, 18, 19}, - {5, 6, 7, 8, -9, 10, 11}, - {9, 10, -11, -12, -13, -14, -15}, - {-13, -14, 15, 16, 17, 18, -19}, - }, - new int[,] { - {1, 2, 3}, - {5, 11, -17}, - {0, -2, -3}, - }, - new int[,] { - {1, 2, 3, 4, -5}, - {5, 11, -17, 11, 7}, - {-9, -10, -11, -14, -15}, - {-9, -10, -11, -14, -6}, - {0, -2, -3, -4, -5}, - }, - new int[,] { - {1, 2, 3, 4, -5, -6, -7}, - {5, 11, -17, 11, -10, 6, 5}, - {5, 6, 7, 8, 9, 10, 11}, - {-9, -10, -11, -14, -15, -16, 1}, - {-9, -10, -11, -14, -15, -6, -2}, - {5, 6, 7, 8, 9, 10, 11}, - {-9, -10, -11, -14, -15, 6, 4}, - }, - new int[,] { - {-9, -10, -11, -14, -15, 6}, - {5, 6, 7, 8, 9, 11}, - {0, 2, 3, 4, 5, 6}, - {9, 10, 11, 12, 13, 14}, - {13, 14, 15, 16, 17, 19}, - {0, 1, 2, 3, 4, 5}, - }, - new int[,] { - {1, 2, 4, 6}, - {5, -6, 7, 11}, - {-1, 4, -5, 6}, - {1, 4, 5, 6}, - }, - new int[,] { - {1, 2, 3, 4, -5, -6, -7}, - {5, 11, -17, 11, -10, 6, 5}, - {-9, -10, -11, -14, -15, -16, 1}, - {-9, -10, -11, -14, 15, -6, -2}, - {-9, -10, -11, -14, -15, 6, 4}, - {5, 11, -17, 11, -10, 6, -5}, - {0, -2, -3, -4, -5, 0, 5}, - } - }; - Array.Reverse(inputB); - var answerA = new int[][,] { - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, 9, 10, 11}, - {9, 10, 11, 12, 13, 14, 15}, - {2, 11, -10, -10, -10, 11, -2}, - {0, 1, 2, 3, 4, 5, 6}, - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, 9, 10, 11}, - }, - new int[,] { - {1, 2, 4, 6}, - {5, -6, 7, 11}, - {-1, 4, -5, 6}, - {6, 11, 6, 6}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6}, - {5, 6, 7, 8, 9, 11}, - {0, 2, 3, 4, 5, 6}, - {9, 10, 11, 12, 13, 14}, - {-15, 9, 5, 13, 17, 4}, - {0, 1, 2, 3, 4, 5}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, 9, 10, 11}, - {9, 10, 11, 12, 13, 14, 15}, - {2, 11, 6, -10, -10, 6, -10}, - {5, 6, 7, 8, -9, 10, 11}, - {9, 10, -11, -12, -13, -14, -15}, - {-13, -14, 15, 16, 17, 18, -19}, - }, - new int[,] { - {1, 2, 3}, - {5, 11, -17}, - {0, -2, -3}, - }, - new int[,] { - {1, 2, 3, 4, -5}, - {5, 11, -17, 11, 7}, - {-9, -10, -11, -14, -15}, - {-9, -10, -11, -14, -6}, - {0, -2, -3, -4, -5}, - }, - new int[,] { - {1, 2, 3, 4, -5, -6, -7}, - {4, 8, 12, 16, 8, -12, 16}, - {5, 6, 7, 8, 9, 10, 11}, - {-9, -10, -11, -14, -15, -16, 1}, - {-9, -10, -11, -14, -15, -6, -2}, - {5, 6, 7, 8, 9, 10, 11}, - {-9, -10, -11, -14, -15, 6, 4}, - }, - new int[,] { - {-9, -10, -11, -14, -15, 6}, - {5, 6, 7, 8, 9, 11}, - {0, 2, 3, 4, 5, 6}, - {9, 10, 11, 12, 13, 14}, - {5, 9, 5, 13, 17, 4}, - {0, 1, 2, 3, 4, 5}, - }, - new int[,] { - {1, 2, 4, 6}, - {5, -6, 7, 11}, - {-1, 4, -5, 6}, - {6, 11, 6, 6}, - }, - new int[,] { - {1, 2, 3, 4, -5, -6, -7}, - {4, 8, 12, 16, 3, 4, 8}, - {-9, -10, -11, -14, -15, -16, 1}, - {-9, -10, -11, -14, 15, -6, -2}, - {-9, -10, -11, -14, -15, 6, 4}, - {5, 11, -17, 11, -10, 6, -5}, - {0, -2, -3, -4, -5, 0, 5}, - } - }; - var answerB = new int[][,] { - new int[,] { - {1, 13, 3, 4, -5, -6, -7}, - {5, 14, -17, 11, -10, 6, 5}, - {-9, 15, -11, -14, -15, -16, 1}, - {-9, 16, -11, -14, 15, -6, -2}, - {-9, 17, -11, -14, -15, 6, 4}, - {5, 18, -17, 11, -10, 6, -5}, - {0, 19, -3, -4, -5, 0, 5}, - }, - new int[,] { - {1, 2, 4, 1}, - {5, -6, 7, 4}, - {-1, 4, -5, 5}, - {1, 4, 5, 6}, - }, - new int[,] { - {-9, -10, -11, -14, 13, 6}, - {5, 6, 7, 8, 14, 11}, - {0, 2, 3, 4, 15, 6}, - {9, 10, 11, 12, 16, 14}, - {13, 14, 15, 16, 17, 19}, - {0, 1, 2, 3, 19, 5}, - }, - new int[,] { - {1, 13, 3, 4, -5, -6, -7}, - {5, 14, -17, 11, -10, 6, 5}, - {5, 15, 7, 8, 9, 10, 11}, - {-9, 16, -11, -14, -15, -16, 1}, - {-9, 17, -11, -14, -15, -6, -2}, - {5, 18, 7, 8, 9, 10, 11}, - {-9, 19, -11, -14, -15, 6, 4}, - }, - new int[,] { - {1, 2, 3, 4, -5}, - {5, 11, -17, 11, 7}, - {-9, -10, -11, -14, -15}, - {-9, -10, -11, -14, -6}, - {0, -2, -3, -4, -5}, - }, - new int[,] { - {1, 2, 3}, - {5, 11, -17}, - {0, -2, -3}, - }, - new int[,] { - {1, 2, 3, 5, 5, 6, 7}, - {5, 6, 7, 11, 9, 10, 11}, - {9, 10, 11, -17, 13, 14, 15}, - {13, 14, 15, 11, 17, 18, 19}, - {5, 6, 7, -10, -9, 10, 11}, - {9, 10, -11, 6, -13, -14, -15}, - {-13, -14, 15, 5, 17, 18, -19}, - }, - new int[,] { - {1, 2, 3, 4, 13, 6}, - {5, 6, 7, 8, 14, 11}, - {0, 2, 3, 4, 15, 6}, - {9, 10, 11, 12, 16, 14}, - {13, 14, 15, 16, 17, 19}, - {0, 1, 2, 3, 19, 5}, - }, - new int[,] { - {1, 2, 4, 1}, - {5, -6, 7, 4}, - {-1, 4, -5, 5}, - {1, 4, 5, 6}, - }, - new int[,] { - {1, 2, 3, 5, 5, 6, 7}, - {5, 6, 7, 11, 9, 10, 11}, - {9, 10, 11, -17, 13, 14, 15}, - {13, 14, 15, 11, 17, 18, 19}, - {0, 1, 2, -10, 4, 5, 6}, - {1, 2, 3, 6, 5, 6, 7}, - {5, 6, 7, 5, 9, 10, 11}, - } - }; - // Act - for (int i = 0; i < answerA.Length; i++) - { - _main.Task1(inputA[i], inputB[i]); - } - // Assert - for (int i = 0; i < answerA.Length; i++) - { - Assert.AreEqual(answerA[i].GetLength(0), inputA[i].GetLength(0)); - Assert.AreEqual(answerA[i].GetLength(1), inputA[i].GetLength(1)); - for (int j = 0; j < answerA[i].GetLength(0); j++) - { - for (int k = 0; k < answerA[i].GetLength(1); k++) - { - Assert.AreEqual(answerA[i][j, k], inputA[i][j, k]); - } - } - Assert.AreEqual(answerB[i].GetLength(0), inputB[i].GetLength(0)); - Assert.AreEqual(answerB[i].GetLength(1), inputB[i].GetLength(1)); - for (int j = 0; j < answerB[i].GetLength(0); j++) - { - for (int k = 0; k < answerB[i].GetLength(1); k++) - { - Assert.AreEqual(answerB[i][j, k], inputB[i][j, k]); - } - } - } - } - [TestMethod] - public void Test02() - { - // Arrange - var inputA = _data.GetMatrixes(); - var inputB = _data.GetMatrixes(); - Array.Reverse(inputB); - var answerA = new int[][,] { - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, 9, 10, 11}, - {9, 10, 11, 12, 13, 14, 15}, - {13, 14, 15, 16, 17, 18, 19}, - {0, 1, 2, 3, 4, 5, 6}, - }, - new int[,] { - {1}, - {5}, - {9}, - {13}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6}, - {5, 6, 7, 8, 9, 11}, - {0, 2, 3, 4, 5, 6}, - }, - new int[,] { - {1, 2, 4, 6}, - {5, -6, 7, 11}, - {-1, 4, -5, 6}, - {1, 4, 5, 6}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, -9, 10, 11}, - {9, 10, -11, -12, -13, -14, -15}, - {-13, -14, 15, 16, 17, 18, -19}, - }, - new int[,] { - {1, 2, 3}, - {5, 11, -17}, - {0, -2, -3}, - }, - new int[,] { - {-9, -10, -11, -14, -15, 6}, - }, - new int[,] { - {1, 2, 3, 4, -5, -6, -7}, - {5, 11, -17, 11, -10, 6, 5}, - {-9, -10, -11, -14, -15, -16, 1}, - {-9, -10, -11, -14, -15, -6, -2}, - {-9, -10, -11, -14, -15, 6, 4}, - }, - new int[,] { - {1, 2, 3, 4, -5, -6, -7}, - {5, 11, -17, 11, -10, 6, 5}, - {-9, -10, -11, -14, -15, -16, 1}, - {-9, -10, -11, -14, 15, -6, -2}, - {-9, -10, -11, -14, -15, 6, 4}, - {5, 11, -17, 11, -10, 6, -5}, - {1, 1, -2, 3, -4, 0, 0}, - {0, -2, -3, -4, -5, 0, 5}, - }, - new int[,] { - {1, 2, 3, 4, -5}, - {2, 6, 10, 14, 1}, - {5, 11, -17, 11, 7}, - {-9, -10, -11, -14, -15}, - {-9, -10, -11, -14, -6}, - {0, -2, -3, -4, -5}, - } - }; - var answerB = new int[][,] { - new int[,] { - {1, 2, 3, 4, -5}, - {5, 11, -17, 11, 7}, - {-9, -10, -11, -14, -15}, - {-9, -10, -11, -14, -6}, - {0, -2, -3, -4, -5}, - }, - new int[,] { - {1, 2, 3, 4, -5, -6, -7}, - {5, 11, -17, 11, -10, 6, 5}, - {-9, -10, -11, -14, -15, -16, 1}, - {-9, -10, -11, -14, 15, -6, -2}, - {-9, -10, -11, -14, -15, 6, 4}, - {5, 11, -17, 11, -10, 6, -5}, - {1, 1, -2, 3, -4, 0, 0}, - {0, -2, -3, -4, -5, 0, 5}, - }, - new int[,] { - {1, 2, 3, 4, -5, -6, -7}, - {5, 11, -17, 11, -10, 6, 5}, - {-9, -10, -11, -14, -15, -16, 1}, - {-9, -10, -11, -14, -15, -6, -2}, - {-9, -10, -11, -14, -15, 6, 4}, - }, - new int[,] { - {-9, -10, -11, -14, -15, 6}, - }, - new int[,] { - {1, 2, 3}, - {5, 11, -17}, - {0, -2, -3}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, -9, 10, 11}, - {9, 10, -11, -12, -13, -14, -15}, - {-13, -14, 15, 16, 17, 18, -19}, - }, - new int[,] { - {1, 2, 4, 6}, - {5, -6, 7, 11}, - {-1, 4, -5, 6}, - {1, 4, 5, 6}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6}, - {5, 6, 7, 8, 9, 11}, - {0, 2, 3, 4, 5, 6}, - }, - new int[,] { - {1}, - {5}, - {9}, - {13}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, 9, 10, 11}, - {9, 10, 11, 12, 13, 14, 15}, - {13, 14, 15, 16, 17, 18, 19}, - {0, 1, 2, 3, 4, 5, 6}, - } - }; - // Act - for (int i = 0; i < answerA.Length; i++) - { - _main.Task2(ref inputA[i], inputB[i]); - } - // Assert - for (int i = 0; i < answerA.Length; i++) - { - Assert.AreEqual(answerA[i].GetLength(0), inputA[i].GetLength(0)); - Assert.AreEqual(answerA[i].GetLength(1), inputA[i].GetLength(1)); - for (int j = 0; j < answerA[i].GetLength(0); j++) - { - for (int k = 0; k < answerA[i].GetLength(1); k++) - { - Assert.AreEqual(answerA[i][j, k], inputA[i][j, k]); - } - } - Assert.AreEqual(answerB[i].GetLength(0), inputB[i].GetLength(0)); - Assert.AreEqual(answerB[i].GetLength(1), inputB[i].GetLength(1)); - for (int j = 0; j < answerB[i].GetLength(0); j++) - { - for (int k = 0; k < answerB[i].GetLength(1); k++) - { - Assert.AreEqual(answerB[i][j, k], inputB[i][j, k]); - } - } - } - } - [TestMethod] - public void Test03() - { - // Arrange - var input = _data.GetMatrixes(); - var answer = new int[][,] { - new int[,] { - {0, 1, 1, 2, 2, 3, 3}, - {2, 3, 3, 4, 4, 5, 5}, - {4, 5, 5, 6, 6, 7, 30}, - {6, 7, 7, 32, 34, 36, 38}, - {0, 0, 1, 1, 2, 2, 3}, - }, - new int[,] { - {2}, - {10}, - {18}, - {26}, - }, - new int[,] { - {0, 1, 1, 2, 2, 12}, - {2, 3, 14, 16, 18, 22}, - {0, 1, 1, 2, 2, 3}, - }, - new int[,] { - {0, 1, 2, 12}, - {2, -3, 14, 22}, - {0, 2, -2, 12}, - {0, 2, 2, 12}, - }, - new int[,] { - {0, 1, 1, 2, 2, 3, 3}, - {2, 3, 3, 4, -4, 5, 22}, - {4, 5, -5, -6, -6, -7, -7}, - {-6, -7, 30, 32, 34, 36, -9}, - }, - new int[,] { - {2, 4, 6}, - {10, 22, -8}, - {0, -1, -1}, - }, - new int[,] { - {-18, -20, -22, -28, -7, 12}, - }, - new int[,] { - {0, 1, 1, 2, -2, -3, -3}, - {10, 22, -8, 22, -5, 12, 2}, - {-4, -5, -5, -7, -7, -8, 0}, - {-4, -5, -5, -7, -7, -3, -1}, - {-4, -5, -5, -7, -7, 12, 2}, - }, - new int[,] { - {0, 1, 1, 2, -2, -3, -3}, - {2, 22, -8, 22, -5, 3, 2}, - {-4, -5, -5, -7, -7, -8, 0}, - {-4, -5, -5, -7, 30, -3, -1}, - {-4, -5, -5, -7, -7, 3, 2}, - {2, 22, -8, 22, -5, 3, -2}, - {0, 0, -1, 1, -2, 0, 0}, - {0, -1, -1, -2, -2, 0, 2}, - }, - new int[,] { - {0, 1, 1, 8, -2}, - {10, 22, -8, 22, 14}, - {-4, -5, -5, -7, -7}, - {-4, -5, -5, -7, -3}, - {0, -1, -1, -2, -2}, - } - }; - // Act - for (int i = 0; i < answer.Length; i++) - { - _main.Task3(input[i]); - } - // Assert - for (int i = 0; i < answer.Length; i++) - { - Assert.AreEqual(answer[i].GetLength(0), input[i].GetLength(0)); - Assert.AreEqual(answer[i].GetLength(1), input[i].GetLength(1)); - for (int j = 0; j < answer[i].GetLength(0); j++) - { - for (int k = 0; k < answer[i].GetLength(1); k++) - { - Assert.AreEqual(answer[i][j, k], input[i][j, k]); - } - } - } - } - [TestMethod] - public void Test04() - { - // Arrange - var inputA = new int[][,] { - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, 9, 10, 11}, - {9, 10, 11, 12, 13, 14, 15}, - {13, 14, 15, 16, 17, 18, 19}, - {0, 1, 2, 3, 4, 5, 6}, - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, 9, 10, 11}, - }, - new int[,] { - {1, 2, 4, 6}, - {5, -6, 7, 11}, - {-1, 4, -5, 6}, - {1, 4, 5, 6}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6}, - {5, 6, 7, 8, 9, 11}, - {0, 2, 3, 4, 5, 6}, - {9, 10, 11, 12, 13, 14}, - {13, 14, 15, 16, 17, 19}, - {0, 1, 2, 3, 4, 5}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, 9, 10, 11}, - {9, 10, 11, 12, 13, 14, 15}, - {13, 14, 15, 16, 17, 18, 19}, - {5, 6, 7, 8, -9, 10, 11}, - {9, 10, -11, -12, -13, -14, -15}, - {-13, -14, 15, 16, 17, 18, -19}, - }, - new int[,] { - {1, 2, 3}, - {5, 11, -17}, - {0, -2, -3}, - }, - new int[,] { - {1, 2, 3, 4, -5}, - {5, 11, -17, 11, 7}, - {-9, -10, -11, -14, -15}, - {-9, -10, -11, -14, -6}, - {0, -2, -3, -4, -5}, - }, - new int[,] { - {1, 2, 3, 4, -5, -6, -7}, - {5, 11, -17, 11, -10, 6, 5}, - {5, 6, 7, 8, 9, 10, 11}, - {-9, -10, -11, -14, -15, -16, 1}, - {-9, -10, -11, -14, -15, -6, -2}, - {5, 6, 7, 8, 9, 10, 11}, - {-9, -10, -11, -14, -15, 6, 4}, - }, - new int[,] { - {-9, -10, -11, -14, -15, 6}, - {5, 6, 7, 8, 9, 11}, - {0, 2, 3, 4, 5, 6}, - {9, 10, 11, 12, 13, 14}, - {13, 14, 15, 16, 17, 19}, - {0, 1, 2, 3, 4, 5}, - }, - new int[,] { - {1, 2, 4, 6}, - {5, -6, 7, 11}, - {-1, 4, -5, 6}, - {1, 4, 5, 6}, - }, - new int[,] { - {1, 2, 3, 4, -5, -6, -7}, - {5, 11, -17, 11, -10, 6, 5}, - {-9, -10, -11, -14, -15, -16, 1}, - {-9, -10, -11, -14, 15, -6, -2}, - {-9, -10, -11, -14, -15, 6, 4}, - {5, 11, -17, 11, -10, 6, -5}, - {0, -2, -3, -4, -5, 0, 5}, - } - }; - var inputB = new int[][,] { - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, 9, 10, 11}, - {9, 10, 11, 12, 13, 14, 15}, - {13, 14, 15, 16, 17, 18, 19}, - {0, 1, 2, 3, 4, 5, 6}, - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, 9, 10, 11}, - }, - new int[,] { - {1, 2, 4, 6}, - {5, -6, 7, 11}, - {-1, 4, -5, 6}, - {1, 4, 5, 6}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6}, - {5, 6, 7, 8, 9, 11}, - {0, 2, 3, 4, 5, 6}, - {9, 10, 11, 12, 13, 14}, - {13, 14, 15, 16, 17, 19}, - {0, 1, 2, 3, 4, 5}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, 9, 10, 11}, - {9, 10, 11, 12, 13, 14, 15}, - {13, 14, 15, 16, 17, 18, 19}, - {5, 6, 7, 8, -9, 10, 11}, - {9, 10, -11, -12, -13, -14, -15}, - {-13, -14, 15, 16, 17, 18, -19}, - }, - new int[,] { - {1, 2, 3}, - {5, 11, -17}, - {0, -2, -3}, - }, - new int[,] { - {1, 2, 3, 4, -5}, - {5, 11, -17, 11, 7}, - {-9, -10, -11, -14, -15}, - {-9, -10, -11, -14, -6}, - {0, -2, -3, -4, -5}, - }, - new int[,] { - {1, 2, 3, 4, -5, -6, -7}, - {5, 11, -17, 11, -10, 6, 5}, - {5, 6, 7, 8, 9, 10, 11}, - {-9, -10, -11, -14, -15, -16, 1}, - {-9, -10, -11, -14, -15, -6, -2}, - {5, 6, 7, 8, 9, 10, 11}, - {-9, -10, -11, -14, -15, 6, 4}, - }, - new int[,] { - {-9, -10, -11, -14, -15, 6}, - {5, 6, 7, 8, 9, 11}, - {0, 2, 3, 4, 5, 6}, - {9, 10, 11, 12, 13, 14}, - {13, 14, 15, 16, 17, 19}, - {0, 1, 2, 3, 4, 5}, - }, - new int[,] { - {1, 2, 4, 6}, - {5, -6, 7, 11}, - {-1, 4, -5, 6}, - {1, 4, 5, 6}, - }, - new int[,] { - {1, 2, 3, 4, -5, -6, -7}, - {5, 11, -17, 11, -10, 6, 5}, - {-9, -10, -11, -14, -15, -16, 1}, - {-9, -10, -11, -14, 15, -6, -2}, - {-9, -10, -11, -14, -15, 6, 4}, - {5, 11, -17, 11, -10, 6, -5}, - {0, -2, -3, -4, -5, 0, 5}, - } - }; - Array.Reverse(inputB); - var answerA = new int[][,] { - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, 9, 10, 11}, - {9, 10, 11, 12, 13, 14, 15}, - {13, 14, 15, 16, 17, 18, 19}, - {0, 1, 2, 3, 4, 5, 6}, - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, 9, 10, 11}, - }, - new int[,] { - {1, 2, 4, 6}, - {5, -6, 7, 11}, - {-1, 4, -5, 6}, - {1, 4, 5, 6}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6}, - {5, 6, 7, 8, 9, 11}, - {0, 2, 3, 4, 5, 6}, - {9, 10, 11, 12, 13, 14}, - {13, 14, 15, 16, 17, 19}, - {0, 1, 2, 3, 4, 5}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, 9, 10, 11}, - {9, 10, 11, 12, 13, 14, 15}, - {13, 14, 15, 16, 17, 18, 19}, - {5, 6, 7, 8, -9, 10, 11}, - {-9, -10, -11, -14, -15, -6, -2}, - {-13, -14, 15, 16, 17, 18, -19}, - }, - new int[,] { - {1, 2, 3}, - {5, 11, -17}, - {0, -2, -3}, - }, - new int[,] { - {1, 2, 3, 4, -5}, - {5, 11, -17, 11, 7}, - {-9, -10, -11, -14, -15}, - {-9, -10, -11, -14, -6}, - {0, -2, -3, -4, -5}, - }, - new int[,] { - {1, 2, 3, 4, -5, -6, -7}, - {5, 11, -17, 11, -10, 6, 5}, - {5, 6, 7, 8, 9, 10, 11}, - {-9, -10, -11, -14, -15, -16, 1}, - {9, 10, -11, -12, -13, -14, -15}, - {5, 6, 7, 8, 9, 10, 11}, - {-9, -10, -11, -14, -15, 6, 4}, - }, - new int[,] { - {-9, -10, -11, -14, -15, 6}, - {5, 6, 7, 8, 9, 11}, - {0, 2, 3, 4, 5, 6}, - {9, 10, 11, 12, 13, 14}, - {13, 14, 15, 16, 17, 19}, - {0, 1, 2, 3, 4, 5}, - }, - new int[,] { - {1, 2, 4, 6}, - {5, -6, 7, 11}, - {-1, 4, -5, 6}, - {1, 4, 5, 6}, - }, - new int[,] { - {1, 2, 3, 4, -5, -6, -7}, - {5, 11, -17, 11, -10, 6, 5}, - {-9, -10, -11, -14, -15, -16, 1}, - {-9, -10, -11, -14, 15, -6, -2}, - {-9, -10, -11, -14, -15, 6, 4}, - {5, 11, -17, 11, -10, 6, -5}, - {0, -2, -3, -4, -5, 0, 5}, - } - }; - var answerB = new int[][,] { - new int[,] { - {1, 2, 3, 4, -5, -6, -7}, - {5, 11, -17, 11, -10, 6, 5}, - {-9, -10, -11, -14, -15, -16, 1}, - {-9, -10, -11, -14, 15, -6, -2}, - {-9, -10, -11, -14, -15, 6, 4}, - {5, 11, -17, 11, -10, 6, -5}, - {0, -2, -3, -4, -5, 0, 5}, - }, - new int[,] { - {1, 2, 4, 6}, - {5, -6, 7, 11}, - {-1, 4, -5, 6}, - {1, 4, 5, 6}, - }, - new int[,] { - {-9, -10, -11, -14, -15, 6}, - {5, 6, 7, 8, 9, 11}, - {0, 2, 3, 4, 5, 6}, - {9, 10, 11, 12, 13, 14}, - {13, 14, 15, 16, 17, 19}, - {0, 1, 2, 3, 4, 5}, - }, - new int[,] { - {1, 2, 3, 4, -5, -6, -7}, - {5, 11, -17, 11, -10, 6, 5}, - {5, 6, 7, 8, 9, 10, 11}, - {-9, -10, -11, -14, -15, -16, 1}, - {9, 10, -11, -12, -13, -14, -15}, - {5, 6, 7, 8, 9, 10, 11}, - {-9, -10, -11, -14, -15, 6, 4}, - }, - new int[,] { - {1, 2, 3, 4, -5}, - {5, 11, -17, 11, 7}, - {-9, -10, -11, -14, -15}, - {-9, -10, -11, -14, -6}, - {0, -2, -3, -4, -5}, - }, - new int[,] { - {1, 2, 3}, - {5, 11, -17}, - {0, -2, -3}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, 9, 10, 11}, - {9, 10, 11, 12, 13, 14, 15}, - {13, 14, 15, 16, 17, 18, 19}, - {5, 6, 7, 8, -9, 10, 11}, - {-9, -10, -11, -14, -15, -6, -2}, - {-13, -14, 15, 16, 17, 18, -19}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6}, - {5, 6, 7, 8, 9, 11}, - {0, 2, 3, 4, 5, 6}, - {9, 10, 11, 12, 13, 14}, - {13, 14, 15, 16, 17, 19}, - {0, 1, 2, 3, 4, 5}, - }, - new int[,] { - {1, 2, 4, 6}, - {5, -6, 7, 11}, - {-1, 4, -5, 6}, - {1, 4, 5, 6}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, 9, 10, 11}, - {9, 10, 11, 12, 13, 14, 15}, - {13, 14, 15, 16, 17, 18, 19}, - {0, 1, 2, 3, 4, 5, 6}, - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, 9, 10, 11}, - } - }; - // Act - for (int i = 0; i < answerA.Length; i++) - { - _main.Task4(inputA[i], inputB[i]); - } - // Assert - for (int i = 0; i < answerA.Length; i++) - { - Assert.AreEqual(answerA[i].GetLength(0), inputA[i].GetLength(0)); - Assert.AreEqual(answerA[i].GetLength(1), inputA[i].GetLength(1)); - for (int j = 0; j < answerA[i].GetLength(0); j++) - { - for (int k = 0; k < answerA[i].GetLength(1); k++) - { - Assert.AreEqual(answerA[i][j, k], inputA[i][j, k]); - } - } - Assert.AreEqual(answerB[i].GetLength(0), inputB[i].GetLength(0)); - Assert.AreEqual(answerB[i].GetLength(1), inputB[i].GetLength(1)); - for (int j = 0; j < answerB[i].GetLength(0); j++) - { - for (int k = 0; k < answerB[i].GetLength(1); k++) - { - Assert.AreEqual(answerB[i][j, k], inputB[i][j, k]); - } - } - } - } - [TestMethod] - public void Test05A() - { - // Arrange - var input = new int[][] { - new int[] { 2, 1, 3, 3, 5, 6, 3, 4 }, - new int[] { 12, 1, 3, 3, 5, -6, -3, 4 }, - new int[] { 5, -2, -8, 1, 9, 3, -7, -4, 6, 0 }, - new int[] { -2, -1, -3, -4 }, - new int[] { 0, 2, 4, 6, 8 }, - new int[] { 2, 1, 3, -3, -5, 6, 3, 4 }, - new int[] { 5, 2, -8, 1, 9, -3, 7, 4, 6 }, - new int[] { 12, -1, 3, -3, 5, -6, 3, 4 }, - new int[] { 5, 2, 8, -1, 9, 3, -7, 4, -6, 0 }, - new int[] { 5, 2, -8, 1, -9, 0, 7, 4, 6, 10 } - }; - var answer = new int[][] { - new int[] { 2, 1, 3, 3, 5, 6, 3, 4 }, - new int[] { 12, 1, 3, 3, 5, -6, -3, 4 }, - new int[] { 5, -8, -7, 1, 9, 3, -4, -2, 6, 0 }, - new int[] { -4, -3, -2, -1 }, - new int[] { 0, 2, 4, 6, 8 }, - new int[] { 2, 1, 3, -5, -3, 6, 3, 4 }, - new int[] { 5, 2, -8, 1, 9, -3, 7, 4, 6 }, - new int[] { 12, -6, 3, -3, 5, -1, 3, 4 }, - new int[] { 5, 2, 8, -7, 9, 3, -6, 4, -1, 0 }, - new int[] { 5, 2, -9, 1, -8, 0, 7, 4, 6, 10 } - }; - // Act - for (int i = 0; i < answer.Length; i++) - { - _main.Task5(input[i], _main.SortNegativeAscending); - } - // Assert - for (int i = 0; i < answer.Length; i++) - { - Assert.AreEqual(answer[i].Length, input[i].Length); - for (int j = 0; j < answer[i].GetLength(0); j++) - { - Assert.AreEqual(answer[i][j], input[i][j]); - } - } - } - [TestMethod] - public void Test05B() - { - // Arrange - var input = new int[][] { - new int[] { 2, 1, 3, 3, 5, 6, 3, 4 }, - new int[] { 12, 1, 3, 3, 5, -6, -3, 4 }, - new int[] { 5, -2, -8, 1, 9, 3, -7, -4, 6, 0 }, - new int[] { -2, -1, -3, -4 }, - new int[] { 0, 2, 4, 6, 8 }, - new int[] { 2, 1, 3, -3, -5, 6, 3, 4 }, - new int[] { 5, 2, -8, 1, 9, -3, 7, 4, 6 }, - new int[] { 12, -1, 3, -3, 5, -6, 3, 4 }, - new int[] { 5, 2, 8, -1, 9, 3, -7, 4, -6, 0 }, - new int[] { 5, 2, -8, 1, -9, 0, 7, 4, 6, 10 } - }; - var answer = new int[][] { - new int[] { 2, 1, 3, 3, 5, 6, 3, 4 }, - new int[] { 12, 1, 3, 3, 5, -3, -6, 4 }, - new int[] { 5, -2, -4, 1, 9, 3, -7, -8, 6, 0 }, - new int[] { -1, -2, -3, -4 }, - new int[] { 0, 2, 4, 6, 8 }, - new int[] { 2, 1, 3, -3, -5, 6, 3, 4 }, - new int[] { 5, 2, -3, 1, 9, -8, 7, 4, 6 }, - new int[] { 12, -1, 3, -3, 5, -6, 3, 4 }, - new int[] { 5, 2, 8, -1, 9, 3, -6, 4, -7, 0 }, - new int[] { 5, 2, -8, 1, -9, 0, 7, 4, 6, 10 } - }; - // Act - for (int i = 0; i < answer.Length; i++) - { - _main.Task5(input[i], _main.SortNegativeDescending); - } - // Assert - for (int i = 0; i < answer.Length; i++) - { - Assert.AreEqual(answer[i].Length, input[i].Length); - for (int j = 0; j < answer[i].GetLength(0); j++) - { - Assert.AreEqual(answer[i][j], input[i][j]); - } - } - } - [TestMethod] - public void Test06A() - { - // Arrange - var input = _data.GetMatrixes(); - var answer = new int[][,] { - new int[,] { - {0, 1, 2, 3, 4, 5, 6}, - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, 9, 10, 11}, - {9, 10, 11, 12, 13, 14, 15}, - {13, 14, 15, 16, 17, 18, 19}, - }, - new int[,] { - {1}, - {5}, - {9}, - {13}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6}, - {0, 2, 3, 4, 5, 6}, - {5, 6, 7, 8, 9, 11}, - }, - new int[,] { - {1, 2, 4, 6}, - {-1, 4, -5, 6}, - {1, 4, 5, 6}, - {5, -6, 7, 11}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {9, 10, -11, -12, -13, -14, -15}, - {5, 6, 7, 8, -9, 10, 11}, - {-13, -14, 15, 16, 17, 18, -19}, - }, - new int[,] { - {0, -2, -3}, - {1, 2, 3}, - {5, 11, -17}, - }, - new int[,] { - {-9, -10, -11, -14, -15, 6}, - }, - new int[,] { - {-9, -10, -11, -14, -15, -6, -2}, - {-9, -10, -11, -14, -15, -16, 1}, - {1, 2, 3, 4, -5, -6, -7}, - {-9, -10, -11, -14, -15, 6, 4}, - {5, 11, -17, 11, -10, 6, 5}, - }, - new int[,] { - {-9, -10, -11, -14, -15, -16, 1}, - {1, 1, -2, 3, -4, 0, 0}, - {1, 2, 3, 4, -5, -6, -7}, - {0, -2, -3, -4, -5, 0, 5}, - {-9, -10, -11, -14, -15, 6, 4}, - {5, 11, -17, 11, -10, 6, 5}, - {5, 11, -17, 11, -10, 6, -5}, - {-9, -10, -11, -14, 15, -6, -2}, - }, - new int[,] { - {-9, -10, -11, -14, -15}, - {-9, -10, -11, -14, -6}, - {0, -2, -3, -4, -5}, - {1, 2, 3, 4, -5}, - {5, 11, -17, 11, 7}, - } - }; - // Act - for (int i = 0; i < answer.Length; i++) - { - _main.Task6(input[i], _main.SortRowsByMaxAscending); - } - // Assert - for (int i = 0; i < answer.Length; i++) - { - Assert.AreEqual(answer[i].GetLength(0), input[i].GetLength(0)); - Assert.AreEqual(answer[i].GetLength(1), input[i].GetLength(1)); - for (int j = 0; j < answer[i].GetLength(0); j++) - { - for (int k = 0; k < answer[i].GetLength(1); k++) - { - Assert.AreEqual(answer[i][j, k], input[i][j, k]); - } - } - } - } - [TestMethod] - public void Test06B() - { - // Arrange - var input = _data.GetMatrixes(); - var answer = new int[][,] { - new int[,] { - {13, 14, 15, 16, 17, 18, 19}, - {9, 10, 11, 12, 13, 14, 15}, - {5, 6, 7, 8, 9, 10, 11}, - {1, 2, 3, 4, 5, 6, 7}, - {0, 1, 2, 3, 4, 5, 6}, - }, - new int[,] { - {13}, - {9}, - {5}, - {1}, - }, - new int[,] { - {5, 6, 7, 8, 9, 11}, - {1, 2, 3, 4, 5, 6}, - {0, 2, 3, 4, 5, 6}, - }, - new int[,] { - {5, -6, 7, 11}, - {1, 2, 4, 6}, - {-1, 4, -5, 6}, - {1, 4, 5, 6}, - }, - new int[,] { - {-13, -14, 15, 16, 17, 18, -19}, - {5, 6, 7, 8, -9, 10, 11}, - {9, 10, -11, -12, -13, -14, -15}, - {1, 2, 3, 4, 5, 6, 7}, - }, - new int[,] { - {5, 11, -17}, - {1, 2, 3}, - {0, -2, -3}, - }, - new int[,] { - {-9, -10, -11, -14, -15, 6}, - }, - new int[,] { - {5, 11, -17, 11, -10, 6, 5}, - {-9, -10, -11, -14, -15, 6, 4}, - {1, 2, 3, 4, -5, -6, -7}, - {-9, -10, -11, -14, -15, -16, 1}, - {-9, -10, -11, -14, -15, -6, -2}, - }, - new int[,] { - {-9, -10, -11, -14, 15, -6, -2}, - {5, 11, -17, 11, -10, 6, 5}, - {5, 11, -17, 11, -10, 6, -5}, - {-9, -10, -11, -14, -15, 6, 4}, - {0, -2, -3, -4, -5, 0, 5}, - {1, 2, 3, 4, -5, -6, -7}, - {1, 1, -2, 3, -4, 0, 0}, - {-9, -10, -11, -14, -15, -16, 1}, - }, - new int[,] { - {5, 11, -17, 11, 7}, - {1, 2, 3, 4, -5}, - {0, -2, -3, -4, -5}, - {-9, -10, -11, -14, -6}, - {-9, -10, -11, -14, -15}, - } - }; - // Act - for (int i = 0; i < answer.Length; i++) - { - _main.Task6(input[i], _main.SortRowsByMaxDescending); - } - // Assert - for (int i = 0; i < answer.Length; i++) - { - Assert.AreEqual(answer[i].GetLength(0), input[i].GetLength(0)); - Assert.AreEqual(answer[i].GetLength(1), input[i].GetLength(1)); - for (int j = 0; j < answer[i].GetLength(0); j++) - { - for (int k = 0; k < answer[i].GetLength(1); k++) - { - Assert.AreEqual(answer[i][j, k], input[i][j, k]); - } - } - } - } - [TestMethod] - public void Test07A() - { - // Arrange - var input = _data.GetMatrixes(); - var answer = new int[][] { - new int[] { 0, 0, 0, 0, 0 }, - new int[] { 0, 0, 0, 0 }, - new int[] { 0, 0, 0 }, - new int[] { 0, 1, 2, 0 }, - new int[] { 0, 1, 5, 3 }, - new int[] { 0, 1, 2 }, - new int[] { 5 }, - new int[] { 3, 2, 6, 7, 5 }, - new int[] { 3, 2, 6, 6, 5, 3, 2, 4 }, - new int[] { 1, 1, 5, 5, 4 } - }; - var test = new int[answer.Length][]; - // Act - for (int i = 0; i < answer.Length; i++) - { - test[i] = _main.Task7(input[i], _main.FindNegativeCountPerRow); - } - // Assert - for (int i = 0; i < answer.Length; i++) - { - Assert.AreEqual(answer[i].Length, test[i].Length); - for (int j = 0; j < answer[i].GetLength(0); j++) - { - Assert.AreEqual(answer[i][j], test[i][j]); - } - } - } - [TestMethod] - public void Test07B() - { - // Arrange - var input = _data.GetMatrixes(); - var answer = new int[][] { - new int[] { 0, 0, 0, 0, 0, 0, 0 }, - new int[] { 0 }, - new int[] { 0, 0, 0, 0, 0, 0 }, - new int[] { -1, -6, -5, 0 }, - new int[] { -13, -14, -11, -12, -9, -14, -15 }, - new int[] { 0, -2, -3 }, - new int[] { -9, -10, -11, -14, -15, 0 }, - new int[] { -9, -10, -11, -14, -5, -6, -2 }, - new int[] { -9, -2, -2, -4, -4, -6, -2 }, - new int[] { -9, -2, -3, -4, -5 } - }; - var test = new int[answer.Length][]; - // Act - for (int i = 0; i < answer.Length; i++) - { - test[i] = _main.Task7(input[i], _main.FindMaxNegativePerColumn); - } - // Assert - for (int i = 0; i < answer.Length; i++) - { - Assert.AreEqual(answer[i].Length, test[i].Length); - for (int j = 0; j < answer[i].GetLength(0); j++) - { - Assert.AreEqual(answer[i][j], test[i][j]); - } - } - } - [TestMethod] - public void Test08A() - { - // Arrange - var input = new int[][,] { - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, 9, 10, 11} - }, - new int[,] { - {1}, - {5} - }, - new int[,] { - {1, 2, 3, 4, 5, 6}, - {5, 6, 7, 8, 9, 11} - }, - new int[,] { - {1, 2, 4, 6}, - {5, -6, 7, 11} - }, - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, -9, 10, 11} - }, - new int[,] { - {1, 2, 3}, - {5, 11, -17} - }, - new int[,] { - {-15, -14, -11, -10, -9, 6}, - {-15, -14, -11, -10, -9, 6}, - }, - new int[,] { - {-7, -6, -5, 1, 2, 3, 4}, - {5, 11, -17, 11, -10, 6, 5} - }, - new int[,] { - {-7, -6, -5, 1, 2, 3, 4}, - {0, -2, -3, -4, -5, 0, 5}, - }, - new int[,] { - {-5, 1, 2, 3, 4}, - {5, 11, -17, 11, 7} - } - }; - var answer = new int[][,] { - new int[,] { - {1}, - }, - new int[,] { - }, - new int[,] { - {1}, - }, - new int[,] { - {0}, - }, - new int[,] { - {0}, - }, - new int[,] { - {0}, - }, - new int[,] { - {1}, - }, - new int[,] { - {0}, - }, - new int[,] { - {0}, - }, - new int[,] { - {0}, - } - }; - var test = new int[answer.Length][,]; - // Act - for (int i = 0; i < answer.Length; i++) - { - test[i] = _main.Task8(input[i], _main.DefineSeq); - } - // Assert - for (int i = 0; i < answer.Length; i++) - { - Assert.AreEqual(answer[i].GetLength(0), test[i].GetLength(0)); - Assert.AreEqual(answer[i].GetLength(1), test[i].GetLength(1)); - for (int j = 0; j < answer[i].GetLength(0); j++) - { - for (int k = 0; k < answer[i].GetLength(1); k++) - { - Assert.AreEqual(answer[i][j, k], test[i][j, k]); - } - } - } - } - [TestMethod] - public void Test08B() - { - // Arrange - var input = new int[][,] { - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, 9, 10, 11} - }, - new int[,] { - {1}, - {5} - }, - new int[,] { - {1, 2, 3, 4, 5, 6}, - {5, 6, 7, 8, 9, 11} - }, - new int[,] { - {1, 2, 4, 6}, - {5, -6, 7, 11} - }, - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, -9, 10, 11} - }, - new int[,] { - {1, 2, 3}, - {5, 11, -17} - }, - new int[,] { - {-15, -14, -11, -10, -9, 6}, - {-15, -14, -11, -10, -9, -9}, - }, - new int[,] { - {-7, -6, -5, 1, 2, 3, 4}, - {5, 11, -17, 11, -10, 6, 5} - }, - new int[,] { - {-7, -6, -5, 1, 2, 3, 4}, - {0, -2, -3, -4, -5, 0, 5}, - }, - new int[,] { - {-5, 1, 2, 3, 4}, - {5, 11, -17, 11, 11} - } - }; - var answer = new int[][,] { - new int[,] { - {1, 7}, - }, - new int[,] { - }, - new int[,] { - {1, 6}, - }, - new int[,] { - {1, 2}, - {2, 6}, - }, - new int[,] { - {1, 4}, - {4, 5}, - {5, 7}, - }, - new int[,] { - {1, 2}, - {2, 3}, - }, - new int[,] { - {-15, 6}, - }, - new int[,] { - {-7, -6}, - {-6, -5}, - {-5, 1}, - {1, 2}, - {2, 3}, - {3, 4}, - }, - new int[,] { - {-7, 2}, - {2, 4}, - }, - new int[,] { - {-5, 1}, - {1, 2}, - {2, 4}, - } - }; - var test = new int[answer.Length][,]; - // Act - for (int i = 0; i < answer.Length; i++) - { - test[i] = _main.Task8(input[i], _main.FindAllSeq); - } - // Assert - for (int i = 0; i < answer.Length; i++) - { - Assert.AreEqual(answer[i].GetLength(0), test[i].GetLength(0)); - Assert.AreEqual(answer[i].GetLength(1), test[i].GetLength(1)); - for (int j = 0; j < answer[i].GetLength(0); j++) - { - for (int k = 0; k < answer[i].GetLength(1); k++) - { - Assert.AreEqual(answer[i][j, k], test[i][j, k]); - } - } - } - } - [TestMethod] - public void Test08C() - { - // Arrange - var input = new int[][,] { - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, 9, 10, 11} - }, - new int[,] { - {1}, - {5} - }, - new int[,] { - {1, 2, 3, 4, 5, 6}, - {5, 6, 7, 8, 9, 11} - }, - new int[,] { - {1, 2, 4, 6}, - {5, -6, 7, 11} - }, - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, -9, 10, 11} - }, - new int[,] { - {1, 2, 3}, - {5, 11, -17} - }, - new int[,] { - {-15, -14, -11, -10, -9, 6}, - {-15, -14, -11, -10, -9, -9}, - }, - new int[,] { - {-7, -6, -5, 1, 2, 3, 4}, - {5, 11, -17, 11, -10, 6, 5} - }, - new int[,] { - {-7, -6, -5, 1, 2, 3, 4}, - {0, -2, -3, -4, -5, 0, 5}, - }, - new int[,] { - {-5, 1, 2, 3, 4}, - {5, 11, -17, 11, 11} - } - }; - var answer = new int[][,] { - new int[,] { - {1, 7}, - }, - new int[,] { - }, - new int[,] { - {1, 6}, - }, - new int[,] { - {2, 6}, - }, - new int[,] { - {1, 4}, - }, - new int[,] { - {1, 2}, - }, - new int[,] { - {-15, 6}, - }, - new int[,] { - {-5, 1}, - }, - new int[,] { - {-7, 2}, - }, - new int[,] { - {-5, 1}, - } - }; - var test = new int[answer.Length][,]; - // Act - for (int i = 0; i < answer.Length; i++) - { - test[i] = _main.Task8(input[i], _main.FindLongestSeq); - } - // Assert - for (int i = 0; i < answer.Length; i++) - { - Assert.AreEqual(answer[i].GetLength(0), test[i].GetLength(0)); - Assert.AreEqual(answer[i].GetLength(1), test[i].GetLength(1)); - for (int j = 0; j < answer[i].GetLength(0); j++) - { - for (int k = 0; k < answer[i].GetLength(1); k++) - { - Assert.AreEqual(answer[i][j, k], test[i][j, k]); - } - } - } - } - [TestMethod] - public void Test09A() - { - // Arrange - var inputA = new double[10] { -0.5, -0.2, -0.8, -0.1, 0.1, 0.3, 0.7, 0.4, 0.4, -0.4 }; - var inputB = new double[10] { 1, 1, 0.8, 1, 1, 1.3, 1.7, 4.4, 0.6, 1.2 }; - var inputH = new double[10] { 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1 }; - var answer = new double[10] { 2, 2, 1, 2, 1, 1, 1, 1, 0, 2 }; - var test = new double[answer.Length]; - // Act - for (int i = 0; i < answer.Length; i++) - { - test[i] = _main.Task9(inputA[i], inputB[i], inputH[i], _main.FuncA); - } - // Assert - Assert.AreEqual(answer.Length, test.Length); - for (int i = 0; i < answer.Length; i++) - { - Assert.AreEqual(answer[i], test[i]); - } - } - [TestMethod] - public void Test09B() - { - // Arrange - var inputA = new double[10] { -2.5, -2.2, -2.8, -2.1, 2.1, 2.3, 2.7, 2.4, 2.4, -2.4 }; - var inputB = new double[10] { 5, 5, 5.8, 5, 5, 5.3, 5.7, 4.4, 6.6, 5.2 }; - var inputH = new double[10] { 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1 }; - var answer = new double[] { 1, 1, 1, 1, 0, 0, 0, 0, 0, 1 }; - var test = new double[answer.Length]; - // Act - for (int i = 0; i < answer.Length; i++) - { - test[i] = _main.Task9(inputA[i], inputB[i], inputH[i], _main.FuncB); - } - // Assert - Assert.AreEqual(answer.Length, test.Length); - for (int i = 0; i < answer.Length; i++) - { - Assert.AreEqual(answer[i], test[i]); - } - } - [TestMethod] - public void Test10A() - { - // Arrange - var input = _data.GetArrayArrays(); - var answer = new int[][][] { - new int[][] { - new int[] { 1, 2, 3, 3, 3, 4, 5, 6 }, - new int[] { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }, - new int[] { 0, 1, 2, 4, 5, 6, 7, 8, 9, 10 }, - new int[] { 9, 7, 6, 5, 4, 3, 2, 1, -8 }, - new int[] { 1, 3, 3, 3, 4, 5, 6, 12 }, - new int[] { 4, 3, 2, 1 }, - new int[] { -4, -3, -2, -1 }, - new int[] { 5 }, - new int[] { 0, 0, 0, 0, 0 }, - new int[] { 1, 1, 1 }, - new int[] { -9, -8, -7, -6, -5, -4, -3, -2, -2, -1 }, - new int[] { 8, 6, 4, 2, 0 }, - }, - new int[][] { - new int[] { 1, 2, 3, 3, 5 }, - new int[] { 9, 8, 5, 2, 1 }, - new int[] { 1, 2, 5, 8, 9 }, - new int[] { 9, 5, 2, 1, -8 }, - new int[] { 0, 1, 3, 5, 12 }, - new int[] { 5, 4, 3, 2, 1 }, - new int[] { -5, -4, -3, -2, -1 }, - new int[] { 0, 0, 0, 0, 0 }, - new int[] { -9, -8, -5, 1, 2 }, - new int[] { 8, 6, 4, 2, 0 }, - }, - new int[][] { - new int[] { -6, -2, 0, 1, 3, 3, 3, 4, 5 }, - }, - new int[][] { - new int[] { 2 }, - new int[] { -2 }, - new int[] { 5 }, - new int[] { 0 }, - }, - new int[][] { - new int[] { 1, 2, 3, 3, 3, 4, 5, 6 }, - new int[] { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }, - new int[] { 0, 1, 2, 4, 5, 6, 7, 8, 9, 10 }, - new int[] { 9, 7, 6, 5, 4, 3, 2, 1, -8 }, - new int[] { 1, 3, 3, 3, 4, 5, 6, 12 }, - new int[] { -1, -2, -2, -3, -4, -5, -6, -7, -8, -9 }, - } - }; - // Act - for (int i = 0; i < answer.Length; i++) - { - _main.Task10(input[i], _main.SortInCheckersOrder); - } - // Assert - Assert.AreEqual(answer.Length, input.Length); - for (int i = 0; i < answer.Length; i++) - { - Assert.AreEqual(answer[i].Length, input[i].Length); - for (int j = 0; j < answer[i].Length; j++) - { - Assert.AreEqual(answer[i][j].Length, input[i][j].Length); - for (int k = 0; k < answer[i][j].Length; k++) - { - Assert.AreEqual(answer[i][j][k], input[i][j][k]); - } - } - } - } - [TestMethod] - public void Test10B() - { - // Arrange - var input = _data.GetArrayArrays(); - var answer = new int[][][] { - new int[][] { - new int[] { 5, 2, 8, 1, 9, 0, 7, 4, 6, 10 }, - new int[] { 5, 2, 8, 1, 9, 3, 7, 4, 6, 0 }, - new int[] { 12, 1, 3, 3, 5, 6, 3, 4 }, - new int[] { 5, 2, -8, 1, 9, 3, 7, 4, 6 }, - new int[] { 2, 1, 3, 3, 5, 6, 3, 4 }, - new int[] { 0, 2, 4, 6, 8 }, - new int[] { 2, 1, 3, 4 }, - new int[] { 5 }, - new int[] { 1, 1, 1 }, - new int[] { 0, 0, 0, 0, 0 }, - new int[] { -2, -1, -3, -4 }, - new int[] { -5, -2, -8, -1, -9, -3, -7, -4, -6, -2 }, - }, - new int[][] { - new int[] { 5, 2, 8, 1, 9 }, - new int[] { 5, 2, 8, 1, 9 }, - new int[] { 12, 1, 3, 0, 5 }, - new int[] { 0, 2, 4, 6, 8 }, - new int[] { 2, 1, 3, 4, 5 }, - new int[] { 2, 1, 3, 3, 5 }, - new int[] { 5, 2, -8, 1, 9 }, - new int[] { 0, 0, 0, 0, 0 }, - new int[] { -2, -1, -3, -4, -5 }, - new int[] { -5, 2, -8, 1, -9 }, - }, - new int[][] { - new int[] { -2, 1, 3, 3, 0, 5, -6, 3, 4 }, - }, - new int[][] { - new int[] { 5 }, - new int[] { 2 }, - new int[] { 0 }, - new int[] { -2 }, - }, - new int[][] { - new int[] { 5, 2, 8, 1, 9, 0, 7, 4, 6, 10 }, - new int[] { 5, 2, 8, 1, 9, 3, 7, 4, 6, 0 }, - new int[] { 12, 1, 3, 3, 5, 6, 3, 4 }, - new int[] { 5, 2, -8, 1, 9, 3, 7, 4, 6 }, - new int[] { 2, 1, 3, 3, 5, 6, 3, 4 }, - new int[] { -5, -2, -8, -1, -9, -3, -7, -4, -6, -2 }, - } - }; - // Act - for (int i = 0; i < answer.Length; i++) - { - _main.Task10(input[i], _main.SortBySumDesc); - } - // Assert - Assert.AreEqual(answer.Length, input.Length); - for (int i = 0; i < answer.Length; i++) - { - Assert.AreEqual(answer[i].Length, input[i].Length); - for (int j = 0; j < answer[i].Length; j++) - { - Assert.AreEqual(answer[i][j].Length, input[i][j].Length); - for (int k = 0; k < answer[i][j].Length; k++) - { - Assert.AreEqual(answer[i][j][k], input[i][j][k]); - } - } - } - } - [TestMethod] - public void Test10C() - { - // Arrange - var input = _data.GetArrayArrays(); - var answer = new int[][][] { - new int[][] { - new int[] { 8, 6, 4, 2, 0 }, - new int[] { -2, -6, -4, -7, -3, -9, -1, -8, -2, -5 }, - new int[] { 1, 1, 1 }, - new int[] { 0, 0, 0, 0, 0 }, - new int[] { 5 }, - new int[] { -4, -3, -1, -2 }, - new int[] { 4, 3, 1, 2 }, - new int[] { 4, 3, 6, 5, 3, 3, 1, 12 }, - new int[] { 6, 4, 7, 3, 9, 1, -8, 2, 5 }, - new int[] { 10, 6, 4, 7, 0, 9, 1, 8, 2, 5 }, - new int[] { 0, 6, 4, 7, 3, 9, 1, 8, 2, 5 }, - new int[] { 4, 3, 6, 5, 3, 3, 1, 2 }, - }, - new int[][] { - new int[] { 8, 6, 4, 2, 0 }, - new int[] { -9, 1, -8, 2, -5 }, - new int[] { 0, 0, 0, 0, 0 }, - new int[] { -5, -4, -3, -1, -2 }, - new int[] { 5, 4, 3, 1, 2 }, - new int[] { 5, 0, 3, 1, 12 }, - new int[] { 9, 1, -8, 2, 5 }, - new int[] { 9, 1, 8, 2, 5 }, - new int[] { 9, 1, 8, 2, 5 }, - new int[] { 5, 3, 3, 1, 2 }, - }, - new int[][] { - new int[] { 4, 3, -6, 5, 0, 3, 3, 1, -2 }, - }, - new int[][] { - new int[] { 0 }, - new int[] { 5 }, - new int[] { -2 }, - new int[] { 2 }, - }, - new int[][] { - new int[] { -2, -6, -4, -7, -3, -9, -1, -8, -2, -5 }, - new int[] { 4, 3, 6, 5, 3, 3, 1, 12 }, - new int[] { 6, 4, 7, 3, 9, 1, -8, 2, 5 }, - new int[] { 10, 6, 4, 7, 0, 9, 1, 8, 2, 5 }, - new int[] { 0, 6, 4, 7, 3, 9, 1, 8, 2, 5 }, - new int[] { 4, 3, 6, 5, 3, 3, 1, 2 }, - } - }; - // Act - for (int i = 0; i < answer.Length; i++) - { - _main.Task10(input[i], _main.TotalReverse); - } - // Assert - Assert.AreEqual(answer.Length, input.Length); - for (int i = 0; i < answer.Length; i++) - { - Assert.AreEqual(answer[i].Length, input[i].Length); - for (int j = 0; j < answer[i].Length; j++) - { - Assert.AreEqual(answer[i][j].Length, input[i][j].Length); - for (int k = 0; k < answer[i][j].Length; k++) - { - Assert.AreEqual(answer[i][j][k], input[i][j][k]); - } - } - } - } - [TestMethod] - public void Test_FindDiagonalMaxIndex() - { - int[,] matrix = { { 1, -2, 4, -2 }, { -1, -2, -3, -5 }, { 4, 5, 3, 3 }, { 3, 5, 6, 3 } }; - int index = _main.FindDiagonalMaxIndex(matrix); - Assert.AreEqual(2, index); - } - - [TestMethod] - public void Test_SwapRowColumn() - { - int[,] A = { { 1, 2 }, { 3, 4 } }; - int[,] B = { { 5, 6 }, { 7, 8 } }; - _main.SwapRowColumn(A, 1, B, 0); // обмен 2-й строки A и 1-го столбца B - int[,] ansA = { { 1, 2 }, { 5, 7} }; - int[,] ansB = { { 3, 6 }, { 4, 8 } }; - CollectionAssert.AreEqual(ansA.Cast().ToArray(), A.Cast().ToArray()); - CollectionAssert.AreEqual(ansB.Cast().ToArray(), B.Cast().ToArray()); - } - - [TestMethod] - public void Test_CountPositiveElementsInRowAndColumn() - { - int[,] matrix = { { 1, -2, 4, -2 }, { -1, -2, -3, -5 }, { 4, 5, 3, -3 }, { 3, 5, 6, 3 } }; - Assert.AreEqual(3, _main.CountPositiveElementsInRow(matrix, 2)); - Assert.AreEqual(2, _main.CountPositiveElementsInColumn(matrix, 1)); - } - - [TestMethod] - public void Test_InsertColumn() - { - int[,] A = { { 1, 2 }, { 3, 4 } }; - int[,] B = { { 5, 6 }, { 7, 8 } }; - _main.InsertColumn(ref A, 0, 1, B); // вставка столбца B[*,1] после строки 0 в A - int[,] expected = { { 1, 2 }, { 6, 8 }, { 3, 4 } }; - CollectionAssert.AreEqual(expected.Cast().ToArray(), A.Cast().ToArray()); - } - - [TestMethod] - public void Test_ChangeMatrixValues() - { - int[,] A = { { -1, -2, -3, -5 }, { 4, 5, 3, 3 }, { 3, 5, 6, 3 } }; - _main.ChangeMatrixValues(A); // 5 наибольших удвоить, остальные уменьшить - int[,] expected = { { 0, -1, -1, -2 }, { 8, 10, 6, 1 }, { 1, 10, 12, 1 } }; - CollectionAssert.AreEqual(expected.Cast().ToArray(), A.Cast().ToArray()); - } - - [TestMethod] - public void Test_CountNegativesPerRowAndFindMaxIndex() - { - int[,] matrix = { { -1, 2 }, { -3, -4 }, { -5, -6 } }; - int[] negatives = _main.CountNegativesPerRow(matrix); - int index = _main.FindMaxIndex(negatives); - Assert.AreEqual(1, index); - } - [TestMethod] - public void Test_SortNegativeAscending() - { - int[] arr = { -3, 2, -1, 4, -5, 4, 5 }; - _main.SortNegativeAscending(arr); - int[] expected = { -5, 2, -3, 4, -1, 4, 5 }; - CollectionAssert.AreEqual(expected.Cast().ToArray(), arr.Cast().ToArray()); - } - [TestMethod] - public void Test_SortNegativeDescending() - { - int[] arr = { -3, 2, -1, 4, -5, 4, 5 }; - _main.SortNegativeDescending(arr); - int[] expected = { -1, 2, -3, 4, -5, 4, 5 }; - CollectionAssert.AreEqual(expected.Cast().ToArray(), arr.Cast().ToArray()); - } - [TestMethod] - public void Test_SortRowsByMaxAscending() - { - int[,] arr = { { -1, -2, -3, -5 }, { 4, 5, 3, 3 }, { 3, 5, -6, 3 } }; - _main.SortRowsByMaxAscending(arr); - int[,] expected = { { -1, -2, -3, -5 }, { 4, 5, 3, 3 }, { 3, 5, -6, 3 } }; - CollectionAssert.AreEqual(expected.Cast().ToArray(), arr.Cast().ToArray()); - } - [TestMethod] - public void Test_SortRowsByMaxDescending() - { - int[,] arr = { { -1, -2, -3, -5 }, { 4, 5, 3, 3 }, { 3, 5, -6, 3 } }; - _main.SortRowsByMaxDescending(arr); - int[,] expected = { { 4, 5, 3, 3 }, { 3, 5, -6, 3 }, { -1, -2, -3, -5 } }; - CollectionAssert.AreEqual(expected.Cast().ToArray(), arr.Cast().ToArray()); - } - - [TestMethod] - public void Test_GetRowMax() - { - int[,] A = { { -1, -2, -3, -5 }, { 4, 5, 3, 3 }, { 3, 5, -6, 3 } }; - Assert.AreEqual(5, _main.GetRowMax(A, 2)); - } - - [TestMethod] - public void Test_FindNegativeCountPerRow() - { - int[,] A = { { -1, 2 }, { -3, -4 }, { 3, 4 } }; - int[] counts = _main.FindNegativeCountPerRow(A); - int[] expected = { 1, 2, 0 }; - CollectionAssert.AreEqual(expected.Cast().ToArray(), counts.Cast().ToArray()); - } - - [TestMethod] - public void Test_FindMaxNegativePerColumn() - { - int[,] A = { { -1, 2, 3 }, { -3, -4, 4 } }; - int[] maxNegatives = _main.FindMaxNegativePerColumn(A); - int[] expected = { -1, -4, 0 }; - CollectionAssert.AreEqual(expected.Cast().ToArray(), maxNegatives.Cast().ToArray()); - } - - [TestMethod] - public void Test_DefineSeq() - { - int[,] A = { { 1, 2, 3 }, { 2, 3, 4 } }; - int[,] seq = _main.DefineSeq(A); - int[,] expected = { { 1 } }; - CollectionAssert.AreEqual(expected.Cast().ToArray(), seq.Cast().ToArray()); - } - [TestMethod] - public void Test_FindAllSeq() - { - int[,] A = { { 1, 2, 3, 4, 5, 6 }, { 2, 3, 4, 2, 0, 0 } }; - int[,] seq = _main.FindAllSeq(A); - int[,] expected = { { 1, 3 }, { 3, 6 } }; - CollectionAssert.AreEqual(expected.Cast().ToArray(), seq.Cast().ToArray()); - } - [TestMethod] - public void Test_FindLongestSeq() - { - int[,] A = { { 1, 2, 3, 4, 5, 6 }, { 2, 3, 4, 2, 0, 0 } }; - int[,] seq = _main.FindLongestSeq(A); - int[,] expected = { { 3, 6 } }; - CollectionAssert.AreEqual(expected.Cast().ToArray(), seq.Cast().ToArray()); - } - [TestMethod] - public void Test_CountSignFlips() - { - int countA = _main.CountSignFlips(-1, 5, 0.1, _main.FuncA); - int countB = _main.CountSignFlips(-1, 5, 0.1, _main.FuncB); - Assert.AreEqual(2, countA); - Assert.AreEqual(1, countB); - } - [TestMethod] - public void Test_SortInCheckersOrder() - { - int[][] arr = new int[][] { new int[] { 1, 10, 4, 7, 8, 4, 2 }, - new int[] { 3, 0, -3, 1, 2, 4, 7, 6, 5, -2, -3 } , - new int[] { -3, 4, 0, 5, 6, 7, 6, 5, 1 } }; - _main.SortInCheckersOrder(arr); - int[][] expected = new int[][] { new int[] { 1, 2, 4, 4, 7, 8, 10 }, - new int[] { 7, 6, 5, 4, 3, 2, 1, 0, -2, -3, -3 } , - new int[] { -3, 0, 1, 4, 5, 5, 6, 6, 7 } }; - CollectionAssert.AreEqual(expected.SelectMany(x => x).Cast().ToArray(), arr.SelectMany(x => x).Cast().ToArray()); - } - [TestMethod] - public void Test_SortBySumDesc() - { - int[][] arr = new int[][] { new int[] { 1, 10, 4, 7, 8, 4, 2 }, - new int[] { 3, 0, -3, 1, 2, 4, 7, 6, 5, -2, -3 } , - new int[] { -3, 4, 0, 5, 6, 7, 6, 5, 1 } }; - _main.SortBySumDesc(arr); - int[][] expected = new int[][] { new int[] { 1, 10, 4, 7, 8, 4, 2 }, - new int[] { -3, 4, 0, 5, 6, 7, 6, 5, 1 }, - new int[] { 3, 0, -3, 1, 2, 4, 7, 6, 5, -2, -3 } }; - CollectionAssert.AreEqual(expected.SelectMany(x => x).Cast().ToArray(), arr.SelectMany(x => x).Cast().ToArray()); - } - [TestMethod] - public void Test_TotalReverse() - { - int[][] arr = new int[][] { new int[] { 1, 10, 4, 7, 8, 4, 2 }, - new int[] { 3, 0, -3, 1, 2, 4, 7, 6, 5, -2, -3 } , - new int[] { -3, 4, 0, 5, 6, 7, 6, 5, 1 } }; - _main.TotalReverse(arr); - int[][] expected = new int[][] { new int[] { 1, 5, 6, 7, 6, 5, 0, 4, -3 }, - new int[] { -3, -2, 5, 6, 7, 4, 2, 1, -3, 0, 3} , - new int[] { 2, 4, 8, 7, 4, 10, 1 }}; - CollectionAssert.AreEqual(expected.SelectMany(x => x).Cast().ToArray(), arr.SelectMany(x => x).Cast().ToArray()); - } - } -} From 87a587608f017ee76d7fe5620c4e3e12e897dfe7 Mon Sep 17 00:00:00 2001 From: Ramy Berrekia Date: Wed, 17 Dec 2025 18:23:39 +0300 Subject: [PATCH 11/12] Delete Lab6test/WhiteTest.cs --- Lab6test/WhiteTest.cs | 1280 ----------------------------------------- 1 file changed, 1280 deletions(-) delete mode 100644 Lab6test/WhiteTest.cs diff --git a/Lab6test/WhiteTest.cs b/Lab6test/WhiteTest.cs deleted file mode 100644 index afb9acbc..00000000 --- a/Lab6test/WhiteTest.cs +++ /dev/null @@ -1,1280 +0,0 @@ -using Lab6; -using Microsoft.ApplicationInsights; -using System.Transactions; - -namespace Lab6test -{ - [TestClass] - public sealed class WhiteTest - { - Lab6.White _main = new Lab6.White(); - const double E = 0.0001; - Data _data = new Data(); - - [TestMethod] - public void Test01() - { - // Arrange - var inputA = new double[][] { - new double[] { 2, 1, 3, 3, 5, 6, 3, 4 }, - new double[] { 12, 1, 3, 3, 5, 6, 13, 4 }, - new double[] { 5, 2, 8, 1, 9, 3, 7, 4, 6, 0 }, - new double[] { -2, -1, -3, -4 }, - new double[] { 0, 2, 4, 6, 8 }, - new double[] { 2, 1, 3, 3, 5, 6, 3, 4 }, - new double[] { 5, 2, -8, 1, 9, 3, 7, 4, 6 }, - new double[] { 12, 1, 3, 3, 5, 6, 3, 4 }, - new double[] { 5, 2, 8, 1, 9, 3, 7, 4, 6, 0 }, - new double[] { 5, 2, 8, 1, 9, 0, 7, 4, 6, 10 } - }; - var inputB = new double[][] { - new double[] { -2, -1, -3, -4 }, - new double[] { 2, 1, 3, 0 }, - new double[] { 0, 2, 4, 6, 8 }, - new double[] { 2, 1, 3, 3, 5, 6, 3, 4 }, - new double[] { 5, 2, -8, 1, 9, 3, 7, 4, 6 }, - new double[] { 12, 1, 3, 3, 5, 6, 3, 4 }, - new double[] { -2, -1, -3, -4 }, - new double[] { 0, 2, 4, 6, 8 }, - new double[] { 2, 1, 3, 3, 5, 6, 3, 4 }, - new double[] { 5, 2, 8, 1, 9, 0, 7, 4, 6 } - }; - var answerA = new double[][] { - new double[] { 2, 1, 3, 3, 5, 3.5, 3, 4 }, - new double[] { 12, 1, 3, 3, 5, 6, 4, 4 }, - new double[] { 5, 2, 8, 1, 4, 3, 7, 4, 6, 0 }, - new double[] { -2, -3.5, -3, -4 }, - new double[] { 0, 2, 4, 6, 8 }, - new double[] { 2, 1, 3, 3, 5, 6, 3, 4 }, - new double[] { 5, 2, -8, 1, 5, 3, 7, 4, 6 }, - new double[] { 3.5714285714285716, 1, 3, 3, 5, 6, 3, 4 }, - new double[] { 5, 2, 8, 1, 4, 3, 7, 4, 6, 0 }, - new double[] { 5, 2, 8, 1, 9, 0, 7, 4, 6, 10 } - }; - var answerB = new double[][] { - new double[] { -2, -1, -3, -4 }, - new double[] { 2, 1, 3, 0 }, - new double[] { 0, 2, 4, 6, 8 }, - new double[] { 2, 1, 3, 3, 5, 6, 3, 4 }, - new double[] { 5, 2, -8, 1, 5, 3, 7, 4, 6 }, - new double[] { 3.5714285714285716, 1, 3, 3, 5, 6, 3, 4 }, - new double[] { -2, -1, -3, -4 }, - new double[] { 0, 2, 4, 6, 8 }, - new double[] { 2, 1, 3, 3, 5, 6, 3, 4 }, - new double[] { 5, 2, 8, 1, 4.25, 0, 7, 4, 6 } - }; - // Act - for (int i = 0; i < answerA.Length; i++) - { - _main.Task1(inputA[i], inputB[i]); - } - // Assert - for (int i = 0; i < answerA.Length; i++) - { - Assert.AreEqual(answerA[i].Length, inputA[i].Length); - for (int j = 0; j < answerA[i].Length; j++) - { - Assert.AreEqual(answerA[i][j], inputA[i][j], E); - } - Assert.AreEqual(answerB[i].Length, inputB[i].Length); - for (int j = 0; j < answerB[i].Length; j++) - { - Assert.AreEqual(answerB[i][j], inputB[i][j], E); - } - } - } - [TestMethod] - public void Test02() - { - // Arrange - var inputA = new int[][,] { - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, 9, 10, 11}, - {9, 10, 11, 12, 13, 14, 15}, - {13, 14, 15, 16, 17, 18, 19}, - {0, 1, 2, 3, 4, 5, 6}, - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, 9, 10, 11}, - }, - new int[,] { - {1, 2, 4, 6}, - {5, -6, 7, 11}, - {-1, 4, -5, 6}, - {1, 4, 5, 6}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6}, - {5, 6, 7, 8, 9, 11}, - {0, 2, 3, 4, 5, 6}, - {9, 10, 11, 12, 13, 14}, - {13, 14, 15, 16, 17, 19}, - {0, 1, 2, 3, 4, 5}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, 9, 10, 11}, - {9, 10, 11, 12, 13, 14, 15}, - {13, 14, 15, 16, 17, 18, 19}, - {5, 6, 7, 8, -9, 10, 11}, - {9, 10, -11, -12, -13, -14, -15}, - {-13, -14, 15, 16, 17, 18, -19}, - }, - new int[,] { - {1, 2, 3}, - {5, 11, -17}, - {0, -2, -3}, - }, - new int[,] { - {1, 2, 3, 4, -5}, - {5, 11, -17, 11, 7}, - {-9, -10, -11, -14, -15}, - {-9, -10, -11, -14, -6}, - {0, -2, -3, -4, -5}, - }, - new int[,] { - {1, 2, 3, 4, -5, -6, -7}, - {5, 11, -17, 11, -10, 6, 5}, - {5, 6, 7, 8, 9, 10, 11}, - {-9, -10, -11, -14, -15, -16, 1}, - {-9, -10, -11, -14, -15, -6, -2}, - {5, 6, 7, 8, 9, 10, 11}, - {-9, -10, -11, -14, -15, 6, 4}, - }, - new int[,] { - {-9, -10, -11, -14, -15, 6}, - {5, 6, 7, 8, 9, 11}, - {0, 2, 3, 4, 5, 6}, - {9, 10, 11, 12, 13, 14}, - {13, 14, 15, 16, 17, 19}, - {0, 1, 2, 3, 4, 5}, - }, - new int[,] { - {1, 2, 4, 6}, - {5, -6, 7, 11}, - {-1, 4, -5, 6}, - {1, 4, 5, 6}, - }, - new int[,] { - {1, 2, 3, 4, -5, -6, -7}, - {5, 11, -17, 11, -10, 6, 5}, - {-9, -10, -11, -14, -15, -16, 1}, - {-9, -10, -11, -14, 15, -6, -2}, - {-9, -10, -11, -14, -15, 6, 4}, - {5, 11, -17, 11, -10, 6, -5}, - {0, -2, -3, -4, -5, 0, 5}, - } - }; - var inputB = new int[][,] { - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, 9, 10, 11}, - {9, 10, 11, 12, 13, 14, 15}, - {13, 14, 15, 16, 17, 18, 19}, - {0, 1, 2, 3, 4, 5, 6}, - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, 9, 10, 11}, - }, - new int[,] { - {1, 2, 4, 6}, - {5, -6, 7, 11}, - {-1, 4, -5, 6}, - {1, 4, 5, 6}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6}, - {5, 6, 7, 8, 9, 11}, - {0, 2, 3, 4, 5, 6}, - {9, 10, 11, 12, 13, 14}, - {13, 14, 15, 16, 17, 19}, - {0, 1, 2, 3, 4, 5}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, 9, 10, 11}, - {9, 10, 11, 12, 13, 14, 15}, - {13, 14, 15, 16, 17, 18, 19}, - {5, 6, 7, 8, -9, 10, 11}, - {9, 10, -11, -12, -13, -14, -15}, - {-13, -14, 15, 16, 17, 18, -19}, - }, - new int[,] { - {1, 2, 3}, - {5, 11, -17}, - {0, -2, -3}, - }, - new int[,] { - {1, 2, 3, 4, -5}, - {5, 11, -17, 11, 7}, - {-9, -10, -11, -14, -15}, - {-9, -10, -11, -14, -6}, - {0, -2, -3, -4, -5}, - }, - new int[,] { - {1, 2, 3, 4, -5, -6, -7}, - {5, 11, -17, 11, -10, 6, 5}, - {5, 6, 7, 8, 9, 10, 11}, - {-9, -10, -11, -14, -15, -16, 1}, - {-9, -10, -11, -14, -15, -6, -2}, - {5, 6, 7, 8, 9, 10, 11}, - {-9, -10, -11, -14, -15, 6, 4}, - }, - new int[,] { - {-9, -10, -11, -14, -15, 6}, - {5, 6, 7, 8, 9, 11}, - {0, 2, 3, 4, 5, 6}, - {9, 10, 11, 12, 13, 14}, - {13, 14, 15, 16, 17, 19}, - {0, 1, 2, 3, 4, 5}, - }, - new int[,] { - {1, 2, 4, 6}, - {5, -6, 7, 11}, - {-1, 4, -5, 6}, - {1, 4, 5, 6}, - }, - new int[,] { - {1, 2, 3, 4, -5, -6, -7}, - {5, 11, -17, 11, -10, 6, 5}, - {-9, -10, -11, -14, -15, -16, 1}, - {-9, -10, -11, -14, 15, -6, -2}, - {-9, -10, -11, -14, -15, 6, 4}, - {5, 11, -17, 11, -10, 6, -5}, - {0, -2, -3, -4, -5, 0, 5}, - } - }; - Array.Reverse(inputB); - var answerA = new int[][,] { - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, 9, 10, 11}, - {9, 10, 11, 12, 13, 14, 15}, - {5, 11, -17, 11, -10, 6, 5}, - {0, 1, 2, 3, 4, 5, 6}, - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, 9, 10, 11}, - }, - new int[,] { - {1, 2, 4, 6}, - {5, -6, 7, 11}, - {-1, 4, -5, 6}, - {1, 4, 5, 6}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6}, - {5, 6, 7, 8, 9, 11}, - {0, 2, 3, 4, 5, 6}, - {9, 10, 11, 12, 13, 14}, - {13, 14, 15, 16, 17, 19}, - {0, 1, 2, 3, 4, 5}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, 9, 10, 11}, - {9, 10, 11, 12, 13, 14, 15}, - {5, 11, -17, 11, -10, 6, 5}, - {5, 6, 7, 8, -9, 10, 11}, - {9, 10, -11, -12, -13, -14, -15}, - {-13, -14, 15, 16, 17, 18, -19}, - }, - new int[,] { - {1, 2, 3}, - {5, 11, -17}, - {0, -2, -3}, - }, - new int[,] { - {1, 2, 3, 4, -5}, - {5, 11, -17, 11, 7}, - {-9, -10, -11, -14, -15}, - {-9, -10, -11, -14, -6}, - {0, -2, -3, -4, -5}, - }, - new int[,] { - {1, 2, 3, 4, -5, -6, -7}, - {13, 14, 15, 16, 17, 18, 19}, - {5, 6, 7, 8, 9, 10, 11}, - {-9, -10, -11, -14, -15, -16, 1}, - {-9, -10, -11, -14, -15, -6, -2}, - {5, 6, 7, 8, 9, 10, 11}, - {-9, -10, -11, -14, -15, 6, 4}, - }, - new int[,] { - {-9, -10, -11, -14, -15, 6}, - {5, 6, 7, 8, 9, 11}, - {0, 2, 3, 4, 5, 6}, - {9, 10, 11, 12, 13, 14}, - {13, 14, 15, 16, 17, 19}, - {0, 1, 2, 3, 4, 5}, - }, - new int[,] { - {1, 2, 4, 6}, - {5, -6, 7, 11}, - {-1, 4, -5, 6}, - {1, 4, 5, 6}, - }, - new int[,] { - {1, 2, 3, 4, -5, -6, -7}, - {13, 14, 15, 16, 17, 18, 19}, - {-9, -10, -11, -14, -15, -16, 1}, - {-9, -10, -11, -14, 15, -6, -2}, - {-9, -10, -11, -14, -15, 6, 4}, - {5, 11, -17, 11, -10, 6, -5}, - {0, -2, -3, -4, -5, 0, 5}, - } - }; - var answerB = new int[][,] { - new int[,] { - {1, 2, 3, 4, -5, -6, -7}, - {13, 14, 15, 16, 17, 18, 19}, - {-9, -10, -11, -14, -15, -16, 1}, - {-9, -10, -11, -14, 15, -6, -2}, - {-9, -10, -11, -14, -15, 6, 4}, - {5, 11, -17, 11, -10, 6, -5}, - {0, -2, -3, -4, -5, 0, 5}, - }, - new int[,] { - {1, 2, 4, 6}, - {5, -6, 7, 11}, - {-1, 4, -5, 6}, - {1, 4, 5, 6}, - }, - new int[,] { - {-9, -10, -11, -14, -15, 6}, - {5, 6, 7, 8, 9, 11}, - {0, 2, 3, 4, 5, 6}, - {9, 10, 11, 12, 13, 14}, - {13, 14, 15, 16, 17, 19}, - {0, 1, 2, 3, 4, 5}, - }, - new int[,] { - {1, 2, 3, 4, -5, -6, -7}, - {13, 14, 15, 16, 17, 18, 19}, - {5, 6, 7, 8, 9, 10, 11}, - {-9, -10, -11, -14, -15, -16, 1}, - {-9, -10, -11, -14, -15, -6, -2}, - {5, 6, 7, 8, 9, 10, 11}, - {-9, -10, -11, -14, -15, 6, 4}, - }, - new int[,] { - {1, 2, 3, 4, -5}, - {5, 11, -17, 11, 7}, - {-9, -10, -11, -14, -15}, - {-9, -10, -11, -14, -6}, - {0, -2, -3, -4, -5}, - }, - new int[,] { - {1, 2, 3}, - {5, 11, -17}, - {0, -2, -3}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, 9, 10, 11}, - {9, 10, 11, 12, 13, 14, 15}, - {5, 11, -17, 11, -10, 6, 5}, - {5, 6, 7, 8, -9, 10, 11}, - {9, 10, -11, -12, -13, -14, -15}, - {-13, -14, 15, 16, 17, 18, -19}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6}, - {5, 6, 7, 8, 9, 11}, - {0, 2, 3, 4, 5, 6}, - {9, 10, 11, 12, 13, 14}, - {13, 14, 15, 16, 17, 19}, - {0, 1, 2, 3, 4, 5}, - }, - new int[,] { - {1, 2, 4, 6}, - {5, -6, 7, 11}, - {-1, 4, -5, 6}, - {1, 4, 5, 6}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, 9, 10, 11}, - {9, 10, 11, 12, 13, 14, 15}, - {5, 11, -17, 11, -10, 6, 5}, - {0, 1, 2, 3, 4, 5, 6}, - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, 9, 10, 11}, - } - }; - // Act - for (int i = 0; i < answerA.Length; i++) - { - _main.Task2(inputA[i], inputB[i]); - } - // Assert - for (int i = 0; i < answerA.Length; i++) - { - Assert.AreEqual(answerA[i].GetLength(0), inputA[i].GetLength(0)); - Assert.AreEqual(answerA[i].GetLength(1), inputA[i].GetLength(1)); - for (int j = 0; j < answerA[i].GetLength(0); j++) - { - for (int k = 0; k < answerA[i].GetLength(1); k++) - { - Assert.AreEqual(answerA[i][j, k], inputA[i][j, k]); - } - } - Assert.AreEqual(answerB[i].GetLength(0), inputB[i].GetLength(0)); - Assert.AreEqual(answerB[i].GetLength(1), inputB[i].GetLength(1)); - for (int j = 0; j < answerB[i].GetLength(0); j++) - { - for (int k = 0; k < answerB[i].GetLength(1); k++) - { - Assert.AreEqual(answerB[i][j, k], inputB[i][j, k]); - } - } - } - } - [TestMethod] - public void Test03() - { - // Arrange - var input = _data.GetMatrixes(); - var answer = new int[10] { 0, 0, 0, 2, 2, 2, 0, 3, 2, 2 }; - var test = new int[answer.Length]; - // Act - for (int i = 0; i < answer.Length; i++) - { - test[i] = _main.Task3(input[i]); - } - // Assert - Assert.AreEqual(answer.Length, test.Length); - for (int i = 0; i < answer.Length; i++) - { - Assert.AreEqual(answer[i], test[i]); - } - } - [TestMethod] - public void Test04() - { - // Arrange - var inputA = _data.GetMatrixes(); - var inputB = _data.GetMatrixes(); - Array.Reverse(inputB); - var answerA = new int[][,] { - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, 9, 10, 11}, - {9, 10, 11, 12, 13, 14, 15}, - {13, 14, 15, 16, 17, 18, 11}, - {0, 1, 2, 3, 4, 5, 6}, - }, - new int[,] { - {1}, - {5}, - {9}, - {15}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6}, - {5, 6, 7, 8, 9, 11}, - {0, 2, 3, 4, 5, 6}, - }, - new int[,] { - {1, 2, 4, 6}, - {5, -6, 7, 6}, - {-1, 4, -5, 6}, - {1, 4, 5, 6}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, -9, 10, 11}, - {9, 10, -11, -12, -13, -14, -15}, - {-13, -14, 15, 16, 17, 11, -19}, - }, - new int[,] { - {1, 2, 3}, - {5, 18, -17}, - {0, -2, -3}, - }, - new int[,] { - {-9, -10, -11, -14, -15, 11}, - }, - new int[,] { - {1, 2, 3, 4, -5, -6, -7}, - {5, 11, -17, 11, -10, 6, 5}, - {-9, -10, -11, -14, -15, -16, 1}, - {-9, -10, -11, -14, -15, -6, -2}, - {-9, -10, -11, -14, -15, 6, 4}, - }, - new int[,] { - {1, 2, 3, 4, -5, -6, -7}, - {5, 11, -17, 11, -10, 6, 5}, - {-9, -10, -11, -14, -15, -16, 1}, - {-9, -10, -11, -14, 13, -6, -2}, - {-9, -10, -11, -14, -15, 6, 4}, - {5, 11, -17, 11, -10, 6, -5}, - {1, 1, -2, 3, -4, 0, 0}, - {0, -2, -3, -4, -5, 0, 5}, - }, - new int[,] { - {1, 2, 3, 4, -5}, - {5, 19, -17, 11, 7}, - {-9, -10, -11, -14, -15}, - {-9, -10, -11, -14, -6}, - {0, -2, -3, -4, -5}, - } - }; - var answerB = new int[][,] { - new int[,] { - {1, 2, 3, 4, -5}, - {5, 19, -17, 11, 7}, - {-9, -10, -11, -14, -15}, - {-9, -10, -11, -14, -6}, - {0, -2, -3, -4, -5}, - }, - new int[,] { - {1, 2, 3, 4, -5, -6, -7}, - {5, 11, -17, 11, -10, 6, 5}, - {-9, -10, -11, -14, -15, -16, 1}, - {-9, -10, -11, -14, 13, -6, -2}, - {-9, -10, -11, -14, -15, 6, 4}, - {5, 11, -17, 11, -10, 6, -5}, - {1, 1, -2, 3, -4, 0, 0}, - {0, -2, -3, -4, -5, 0, 5}, - }, - new int[,] { - {1, 2, 3, 4, -5, -6, -7}, - {5, 11, -17, 11, -10, 6, 5}, - {-9, -10, -11, -14, -15, -16, 1}, - {-9, -10, -11, -14, -15, -6, -2}, - {-9, -10, -11, -14, -15, 6, 4}, - }, - new int[,] { - {-9, -10, -11, -14, -15, 11}, - }, - new int[,] { - {1, 2, 3}, - {5, 18, -17}, - {0, -2, -3}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, -9, 10, 11}, - {9, 10, -11, -12, -13, -14, -15}, - {-13, -14, 15, 16, 17, 11, -19}, - }, - new int[,] { - {1, 2, 4, 6}, - {5, -6, 7, 6}, - {-1, 4, -5, 6}, - {1, 4, 5, 6}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6}, - {5, 6, 7, 8, 9, 11}, - {0, 2, 3, 4, 5, 6}, - }, - new int[,] { - {1}, - {5}, - {9}, - {15}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, 9, 10, 11}, - {9, 10, 11, 12, 13, 14, 15}, - {13, 14, 15, 16, 17, 18, 11}, - {0, 1, 2, 3, 4, 5, 6}, - } - }; - // Act - for (int i = 0; i < answerA.Length; i++) - { - _main.Task4(inputA[i], inputB[i]); - } - // Assert - for (int i = 0; i < answerA.Length; i++) - { - Assert.AreEqual(answerA[i].GetLength(0), inputA[i].GetLength(0)); - for (int j = 0; j < answerA[i].GetLength(0); j++) - { - Assert.AreEqual(answerA[i].GetLength(1), inputA[i].GetLength(1)); - for (int k = 0; k < answerA[i].GetLength(1); k++) - { - Assert.AreEqual(answerA[i][j, k], inputA[i][j, k]); - } - } - Assert.AreEqual(answerB[i].GetLength(0), inputB[i].GetLength(0)); - for (int j = 0; j < answerB[i].GetLength(0); j++) - { - Assert.AreEqual(answerB[i].GetLength(1), inputB[i].GetLength(1)); - for (int k = 0; k < answerB[i].GetLength(1); k++) - { - Assert.AreEqual(answerB[i][j, k], inputB[i][j, k]); - } - } - } - } - [TestMethod] - public void Test05() - { - // Arrange - var inputA = _data.GetMatrixes(); - var inputB = _data.GetMatrixes(); - Array.Reverse(inputB); - var answerA = new int[][,] { - new int[,] { - {1, 2, 3, 4, 5, 6, 2}, - {5, 6, 7, 8, 9, 10, 11}, - {9, 10, 11, 12, 13, 14, -10}, - {13, 14, 15, 16, 17, 18, -10}, - {0, 1, 2, 3, 4, 5, -2}, - }, - new int[,] { - {1}, - {5}, - {9}, - {13}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6}, - {5, 6, 7, 8, 9, 11}, - {0, 2, 3, 4, 5, 6}, - }, - new int[,] { - {1, 2, 4, 6}, - {5, -6, 7, 11}, - {-1, 4, -5, 6}, - {1, 4, 5, 6}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, -9, 10, 11}, - {9, 10, -11, -12, -13, -14, -15}, - {-13, -14, 15, 16, 17, 18, -19}, - }, - new int[,] { - {1, 2, 3}, - {5, 11, -17}, - {0, -2, -3}, - }, - new int[,] { - {-9, -10, -11, -14, -15, 6}, - }, - new int[,] { - {1, 2, 3, 4, -5, -6, -7}, - {5, 11, -17, 11, -10, 6, 5}, - {-9, -10, -11, -14, -15, -16, 1}, - {-9, -10, -11, -14, -15, -6, -2}, - {-9, -10, -11, -14, -15, 6, 4}, - }, - new int[,] { - {1, 2, 3, 4, -5, -6, -7}, - {5, 11, -17, 11, -10, 6, 5}, - {-9, -10, -11, -14, -15, -16, 1}, - {-9, -10, -11, -14, 15, -6, -2}, - {-9, -10, -11, -14, -15, 6, 4}, - {5, 11, -17, 11, -10, 6, -5}, - {1, 1, -2, 3, -4, 0, 0}, - {0, -2, -3, -4, -5, 0, 5}, - }, - new int[,] { - {1, 7, 3, 4, -5}, - {5, 11, -17, 11, 7}, - {-9, 15, -11, -14, -15}, - {-9, 19, -11, -14, -6}, - {0, 6, -3, -4, -5}, - } - }; - var answerB = new int[][,] { - new int[,] { - {1, 7, 3, 4, -5}, - {5, 11, -17, 11, 7}, - {-9, 15, -11, -14, -15}, - {-9, 19, -11, -14, -6}, - {0, 6, -3, -4, -5}, - }, - new int[,] { - {1, 2, 3, 4, -5, -6, -7}, - {5, 11, -17, 11, -10, 6, 5}, - {-9, -10, -11, -14, -15, -16, 1}, - {-9, -10, -11, -14, 15, -6, -2}, - {-9, -10, -11, -14, -15, 6, 4}, - {5, 11, -17, 11, -10, 6, -5}, - {1, 1, -2, 3, -4, 0, 0}, - {0, -2, -3, -4, -5, 0, 5}, - }, - new int[,] { - {1, 2, 3, 4, -5, -6, -7}, - {5, 11, -17, 11, -10, 6, 5}, - {-9, -10, -11, -14, -15, -16, 1}, - {-9, -10, -11, -14, -15, -6, -2}, - {-9, -10, -11, -14, -15, 6, 4}, - }, - new int[,] { - {-9, -10, -11, -14, -15, 6}, - }, - new int[,] { - {1, 2, 3}, - {5, 11, -17}, - {0, -2, -3}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, -9, 10, 11}, - {9, 10, -11, -12, -13, -14, -15}, - {-13, -14, 15, 16, 17, 18, -19}, - }, - new int[,] { - {1, 2, 4, 6}, - {5, -6, 7, 11}, - {-1, 4, -5, 6}, - {1, 4, 5, 6}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6}, - {5, 6, 7, 8, 9, 11}, - {0, 2, 3, 4, 5, 6}, - }, - new int[,] { - {1}, - {5}, - {9}, - {13}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6, 2}, - {5, 6, 7, 8, 9, 10, 11}, - {9, 10, 11, 12, 13, 14, -10}, - {13, 14, 15, 16, 17, 18, -10}, - {0, 1, 2, 3, 4, 5, -2}, - } - }; - // Act - for (int i = 0; i < answerA.Length; i++) - { - _main.Task5(inputA[i], inputB[i]); - } - // Assert - for (int i = 0; i < answerA.Length; i++) - { - Assert.AreEqual(answerA[i].GetLength(0), inputA[i].GetLength(0)); - for (int j = 0; j < answerA[i].GetLength(0); j++) - { - Assert.AreEqual(answerA[i].GetLength(1), inputA[i].GetLength(1)); - for (int k = 0; k < answerA[i].GetLength(1); k++) - { - Assert.AreEqual(answerA[i][j, k], inputA[i][j, k]); - } - } - Assert.AreEqual(answerB[i].GetLength(0), inputB[i].GetLength(0)); - for (int j = 0; j < answerB[i].GetLength(0); j++) - { - Assert.AreEqual(answerB[i].GetLength(1), inputB[i].GetLength(1)); - for (int k = 0; k < answerB[i].GetLength(1); k++) - { - Assert.AreEqual(answerB[i][j, k], inputB[i][j, k]); - } - } - } - } - [TestMethod] - public void Test06A() - { - // Arrange - var input = _data.GetMatrixes(); - var answer = new int[][,] { - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, 9, 10, 11}, - {9, 10, 11, 12, 13, 14, 15}, - {13, 14, 15, 16, 17, 18, 19}, - {0, 1, 2, 3, 4, 5, 6}, - }, - new int[,] { - {1}, - {5}, - {9}, - {13}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6}, - {5, 6, 7, 8, 9, 11}, - {0, 2, 3, 4, 5, 6}, - }, - new int[,] { - {-6, 2, 4, 6}, - {5, -5, 7, 11}, - {-1, 4, 1, 6}, - {1, 4, 5, 6}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, -9, 10, 11}, - {9, 10, -11, -12, -13, -14, -15}, - {-13, -14, 15, 16, 17, 18, -19}, - }, - new int[,] { - {-3, 2, 3}, - {5, 1, -17}, - {0, -2, 11}, - }, - new int[,] { - {-9, -10, -11, -14, -15, 6}, - }, - new int[,] { - {1, 2, 3, 4, -5, -6, -7}, - {5, 11, -17, 11, -10, 6, 5}, - {-9, -10, -11, -14, -15, -16, 1}, - {-9, -10, -11, -14, -15, -6, -2}, - {-9, -10, -11, -14, -15, 6, 4}, - }, - new int[,] { - {1, 2, 3, 4, -5, -6, -7}, - {5, 11, -17, 11, -10, 6, 5}, - {-9, -10, -11, -14, -15, -16, 1}, - {-9, -10, -11, -14, 15, -6, -2}, - {-9, -10, -11, -14, -15, 6, 4}, - {5, 11, -17, 11, -10, 6, -5}, - {1, 1, -2, 3, -4, 0, 0}, - {0, -2, -3, -4, -5, 0, 5}, - }, - new int[,] { - {-14, 2, 3, 4, -5}, - {5, -11, -17, 11, 7}, - {-9, -10, -5, -14, -15}, - {-9, -10, -11, 1, -6}, - {0, -2, -3, -4, 11}, - } - }; - // Act - for (int i = 0; i < answer.Length; i++) - { - _main.Task6(input[i], _main.SortDiagonalAscending); - } - // Assert - for (int i = 0; i < answer.Length; i++) - { - Assert.AreEqual(answer[i].GetLength(0), input[i].GetLength(0)); - for (int j = 0; j < answer[i].GetLength(0); j++) - { - Assert.AreEqual(answer[i].GetLength(1), input[i].GetLength(1)); - for (int k = 0; k < answer[i].GetLength(1); k++) - { - Assert.AreEqual(answer[i][j, k], input[i][j, k]); - } - } - } - } - [TestMethod] - public void Test06B() - { - // Arrange - var input = _data.GetMatrixes(); - var answer = new int[][,] { - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, 9, 10, 11}, - {9, 10, 11, 12, 13, 14, 15}, - {13, 14, 15, 16, 17, 18, 19}, - {0, 1, 2, 3, 4, 5, 6}, - }, - new int[,] { - {1}, - {5}, - {9}, - {13}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6}, - {5, 6, 7, 8, 9, 11}, - {0, 2, 3, 4, 5, 6}, - }, - new int[,] { - {6, 2, 4, 6}, - {5, 1, 7, 11}, - {-1, 4, -5, 6}, - {1, 4, 5, -6}, - }, - new int[,] { - {1, 2, 3, 4, 5, 6, 7}, - {5, 6, 7, 8, -9, 10, 11}, - {9, 10, -11, -12, -13, -14, -15}, - {-13, -14, 15, 16, 17, 18, -19}, - }, - new int[,] { - {11, 2, 3}, - {5, 1, -17}, - {0, -2, -3}, - }, - new int[,] { - {-9, -10, -11, -14, -15, 6}, - }, - new int[,] { - {1, 2, 3, 4, -5, -6, -7}, - {5, 11, -17, 11, -10, 6, 5}, - {-9, -10, -11, -14, -15, -16, 1}, - {-9, -10, -11, -14, -15, -6, -2}, - {-9, -10, -11, -14, -15, 6, 4}, - }, - new int[,] { - {1, 2, 3, 4, -5, -6, -7}, - {5, 11, -17, 11, -10, 6, 5}, - {-9, -10, -11, -14, -15, -16, 1}, - {-9, -10, -11, -14, 15, -6, -2}, - {-9, -10, -11, -14, -15, 6, 4}, - {5, 11, -17, 11, -10, 6, -5}, - {1, 1, -2, 3, -4, 0, 0}, - {0, -2, -3, -4, -5, 0, 5}, - }, - new int[,] { - {11, 2, 3, 4, -5}, - {5, 1, -17, 11, 7}, - {-9, -10, -5, -14, -15}, - {-9, -10, -11, -11, -6}, - {0, -2, -3, -4, -14}, - } - }; - // Act - for (int i = 0; i < answer.Length; i++) - { - _main.Task6(input[i], _main.SortDiagonalDescending); - } - // Assert - for (int i = 0; i < answer.Length; i++) - { - Assert.AreEqual(answer[i].GetLength(0), input[i].GetLength(0)); - for (int j = 0; j < answer[i].GetLength(0); j++) - { - Assert.AreEqual(answer[i].GetLength(1), input[i].GetLength(1)); - for (int k = 0; k < answer[i].GetLength(1); k++) - { - Assert.AreEqual(answer[i][j, k], input[i][j, k]); - } - } - } - } - [TestMethod] - public void Test07() - { - // Arrange - var inputN = new int[10] { 1, 2, 3, 10, 10, 20, 9, 10, 12, 5 }; - var inputK = new int[10] { 1, 2, 2, 1, 10, 10, 10, 9, 2, 2 }; - var answer = new long[10] { 1, 1, 3, 10, 1, 184756, 0, 10, 66, 10 }; - var test = new long[answer.Length]; - // Act - for (int i = 0; i < answer.Length; i++) - { - test[i] = _main.Task7(inputN[i], inputK[i]); - } - // Assert - Assert.AreEqual(answer.Length, test.Length); - for (int i = 0; i < answer.Length; i++) - { - Assert.AreEqual(answer[i], test[i]); - } - } - [TestMethod] - public void Test08A() - { - // Arrange - var inputV = new double[10] { 1, 2, 3.5, 0.1, 10, 99, 49, 50, 120, 0.75 }; - var inputA = new double[10] { 1, 0.2, 3.5, 11.1, 100, 0.1, 1, 1, 0.1, 0.25 }; - var answer = new double[10] { 55, 29.000000000000007, 192.5, 500.5, 4600, 994.4999999999998, 535, 545, 1204.4999999999998, 18.75 }; - var test = new double[answer.Length]; - // Act - for (int i = 0; i < answer.Length; i++) - { - test[i] = _main.Task8(inputV[i], inputA[i], _main.GetDistance); - } - // Assert - Assert.AreEqual(answer.Length, test.Length); - for (int i = 0; i < answer.Length; i++) - { - Assert.AreEqual(answer[i], test[i], E); - } - } - [TestMethod] - public void Test08B() - { - // Arrange - var inputV = new double[10] { 1, 2, 3.5, 0.1, 10, 99, 49, 50, 120, 0.75 }; - var inputA = new double[10] { 1, 0.2, 3.5, 11.1, 100, 0.1, 1, 1, 0.1, 0.25 }; - var answer = new double[10] { 14, 24, 8, 5, 2, 2, 3, 2, 1, 26 }; - var test = new double[answer.Length]; - // Act - for (int i = 0; i < answer.Length; i++) - { - test[i] = _main.Task8(inputV[i], inputA[i], _main.GetTime); - } - // Assert - Assert.AreEqual(answer.Length, test.Length); - for (int i = 0; i < answer.Length; i++) - { - Assert.AreEqual(answer[i], test[i]); - } - } - [TestMethod] - public void Test09() - { - // Arrange - var input = _data.GetArrayArrays(); - var answer = new int[5] { 89, 34, 1, 0, 84 }; - var test = new int[answer.Length]; - // Act - for (int i = 0; i < answer.Length; i++) - { - test[i] = _main.Task9(input[i]); - } - // Assert - Assert.AreEqual(answer.Length, test.Length); - for (int i = 0; i < answer.Length; i++) - { - Assert.AreEqual(answer[i], test[i]); - } - } - [TestMethod] - public void Test10A() - { - // Arrange - var input = _data.GetArrayArrays(); - var answer = new int[5] { 54, 34, 6, 2, 42 }; - var test = new int[answer.Length]; - // Act - for (int i = 0; i < answer.Length; i++) - { - test[i] = _main.Task10(input[i], _main.CountPositive); - } - // Assert - Assert.AreEqual(answer.Length, test.Length); - for (int i = 0; i < answer.Length; i++) - { - Assert.AreEqual(answer[i], test[i]); - } - } - [TestMethod] - public void Test10B() - { - // Arrange - var input = _data.GetArrayArrays(); - var answer = new int[5] { 12, 12, 5, 5, 12 }; - var test = new int[answer.Length]; - // Act - for (int i = 0; i < answer.Length; i++) - { - test[i] = _main.Task10(input[i], _main.FindMax); - } - // Assert - Assert.AreEqual(answer.Length, test.Length); - for (int i = 0; i < answer.Length; i++) - { - Assert.AreEqual(answer[i], test[i]); - } - } - [TestMethod] - public void Test10C() - { - // Arrange - var input = _data.GetArrayArrays(); - var answer = new int[5] { 10, 5, 9, 1, 10 }; - var test = new int[answer.Length]; - // Act - for (int i = 0; i < answer.Length; i++) - { - test[i] = _main.Task10(input[i], _main.FindMaxRowLength); - } - // Assert - Assert.AreEqual(answer.Length, test.Length); - for (int i = 0; i < answer.Length; i++) - { - Assert.AreEqual(answer[i], test[i]); - } - } - [TestMethod] - public void Test_FindMaxIndex() - { - double[] arr = { 5, -5, -9, 2, 9, 9, 9, 8.5, 0, -11 }; - int expected = 4; - int actual = _main.FindMaxIndex(arr); - Assert.AreEqual(expected, actual); - } - - [TestMethod] - public void Test_FindMaxRowIndexInColumn() - { - int[,] matrix = { - {7, 8, 10}, - {4, 5, 6}, - {1, 9, 3}, - {14, -10, 0} - }; - int expected = 2; - int actual = _main.FindMaxRowIndexInColumn(matrix, 1); - Assert.AreEqual(expected, actual); - } - [TestMethod] - public void Test_GetNegativeCountPerRow() - { - int[,] matrix = { - {-7, 8, 10}, - {4, 5, 6}, - {-1, -9, -3}, - {14, -10, 0} - }; - int[] expected = new int[] {1, 0, 3, 1}; - var actual = _main.GetNegativeCountPerRow(matrix); - CollectionAssert.AreEqual(expected.Cast().ToArray(), actual.Cast().ToArray()); - } - [TestMethod] - public void Test_FindMax() - { - int[,] matrix = { - {-7, 8, 10}, - {4, 5, 6}, - {-1, -9, -3}, - {14, -10, 14} - }; - int expected = 14, r = 3, c = 0; - var actual = _main.FindMax(matrix, out int row, out int col); - Assert.AreEqual(expected, actual); - Assert.AreEqual(r, row); - Assert.AreEqual(c, col); - } - [TestMethod] - public void Test_SwapColumns() - { - int[,] A = { - {1, 2, 3}, - {4, 5, 6}, - {7, 8, 9} - }; - - int[,] B = { - {9, 8, 7}, - {6, 5, 4}, - {3, 2, 1} - }; - - // обмен 1-го и 2-го столбцов - _main.SwapColumns(A, 0, B, 2); - - int[,] expectedA = { - {7, 2, 3}, - {4, 5, 6}, - {1, 8, 9} - }; - - CollectionAssert.AreEqual(expectedA.Cast().ToArray(), A.Cast().ToArray()); - } - [TestMethod] - public void Test_SortDiagonalAscending() - { - int[,] matrix = { - {9, 2, 3}, - {4, 7, 6}, - {5, 8, 1} - }; - - _main.SortDiagonalAscending(matrix); - - int[] expectedDiag = new int[] { 1, 7, 9 }; - int[] actualDiag = { matrix[0, 0], matrix[1, 1], matrix[2, 2] }; - CollectionAssert.AreEqual(expectedDiag, actualDiag); - } - - [TestMethod] - public void Test_SortDiagonalDescending() - { - int[,] matrix = { - {1, 2, 3}, - {4, 5, 6}, - {7, 8, 9} - }; - - _main.SortDiagonalDescending(matrix); - - int[] expectedDiag = { 9, 5, 1 }; - int[] actualDiag = { matrix[0, 0], matrix[1, 1], matrix[2, 2] }; - CollectionAssert.AreEqual(expectedDiag, actualDiag); - } - [TestMethod] - public void Test_Factorial() - { - long f0 = _main.Factorial(0); - long f5 = _main.Factorial(5); - long f10 = _main.Factorial(10); - - Assert.AreEqual(1, f0); - Assert.AreEqual(120, f5); - Assert.AreEqual(3628800, f10); - } - [TestMethod] - public void Test_GetDistance() - { - double v = 10, a = 1; - double expected = 10 * 10 + (1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 +9); - double actual = _main.GetDistance(v, a); - Assert.AreEqual(145, actual, E); - } - [TestMethod] - public void Test_GetTime() - { - double v = 10, a = 2; - double actual = _main.GetTime(v, a); - int expected = 7; - Assert.AreEqual(expected, actual); - } - [TestMethod] - public void Test_SwapFromLeft() - { - int[] arr = { 1, 2, 3, 4, 5, 6 }; - _main.SwapFromLeft(arr); - int[] expected = { 2, 1, 4, 3, 6, 5 }; - CollectionAssert.AreEqual(expected, arr); - } - [TestMethod] - public void Test_SwapFromRight() - { - int[] arr = { 1, 2, 3, 4, 5, 6 }; - _main.SwapFromRight(arr); - int[] expected = { 2, 1, 4, 3, 6, 5 }; - CollectionAssert.AreEqual(expected, arr); - } - [TestMethod] - public void Test_GetSum() - { - int[] arr = { 10, 5, 3, 7, 9, -5 }; - int expected = 5 + 7 - 5; // индексы 1, 3, 5 - int actual = _main.GetSum(arr); - Assert.AreEqual(expected, actual); - } - [TestMethod] - public void Test_CountPositive() - { - int[][] array = { - new int[] { 1, -2, 3 }, - new int[] { -1, 0, 5 } - }; - int expected = 3; - int actual = _main.CountPositive(array); - Assert.AreEqual(expected, actual); - } - [TestMethod] - public void Test_FindMax_Jagged() - { - int[][] array = { - new int[] { 1, -2, 3 }, - new int[] { -1, 0, 5 } - }; - int expected = 5; - int actual = _main.FindMax(array); - Assert.AreEqual(expected, actual); - } - [TestMethod] - public void Test_FindMaxRowLength() - { - int[][] array = { - new int[] { 1, 2 }, - new int[] { 3, 4, 5, 6 } - }; - int expected = 4; - int actual = _main.FindMaxRowLength(array); - Assert.AreEqual(expected, actual); - } - } -} From 6739970dd2ec24cc50dbd6e0032e82537fcbbacf Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 1 Apr 2026 15:35:15 +0000 Subject: [PATCH 12/12] Add CLAUDE.md with codebase overview and development conventions Documents project structure, build/test commands, task descriptions, helper methods, code conventions, CI pipeline behavior, and common pitfalls for AI assistants working in this repository. https://claude.ai/code/session_01KGGqsKcCskVGJSCsNuGzXw --- CLAUDE.md | 169 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 169 insertions(+) create mode 100644 CLAUDE.md diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 00000000..0a07ef8f --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,169 @@ +# CLAUDE.md — BIVT-25 Lab-6 + +This file describes the codebase structure, build/test workflows, and conventions for AI assistants working in this repository. + +--- + +## Repository Overview + +**BIVT-25 Lab-6** is a C# (.NET 8.0) academic programming assignment. Students implement 10 algorithmic tasks (array and matrix operations) inside the `Green` class. The test suite is pre-written and immutable; the goal is to make all tests in `GreenTest` pass. + +--- + +## Directory Structure + +``` +BIVT-25-Lab-6/ +├── .github/workflows/ +│ └── Tests_runner.yml # CI: build + cascade test runner +├── Lab6/ # Main implementation project +│ ├── Green.cs # PRIMARY FILE — implement Task1–Task10 and helpers here +│ ├── Program.cs # Entry point (Main is empty; not used) +│ ├── Shims.cs # Placeholder stubs (do not modify) +│ ├── Lab6.csproj # Project file (OutputType: Exe, net8.0) +│ └── Lab6.sln # Visual Studio solution +└── Lab6test/ # Test project (do not modify) + ├── GreenTest.cs # Test class for Green (1028 lines, 20+ test methods) + ├── Data.cs # Test fixtures (10 matrices, 5 jagged arrays) + ├── MSTestSettings.cs # Parallelization config + └── Lab6test.csproj # Test project file +``` + +--- + +## The Only File to Edit + +**`Lab6/Green.cs`** is the sole file requiring implementation work. + +- Class: `Lab6.Green` +- Namespace: `Lab6` +- Public delegate defined at namespace level: `public delegate void Sorting(int[] row);` +- Methods `Task1` through `Task10` contain `// code here` … `// end` markers where logic is implemented +- Helper methods below the task methods are also part of the class + +**Do not modify** `GreenTest.cs`, `Data.cs`, `MSTestSettings.cs`, `Shims.cs`, or any `.csproj`/`.sln` file. + +--- + +## Build & Test Commands + +All commands run from the repository root. + +### Restore dependencies +```bash +dotnet restore Lab6/Lab6.sln +``` + +### Build +```bash +dotnet build Lab6/Lab6.sln --configuration Debug --no-restore +``` + +### Run all GreenTest tests +```bash +dotnet test Lab6test/Lab6test.csproj --configuration Debug --filter "FullyQualifiedName~GreenTest" +``` + +### Run a single test method (e.g., Test01) +```bash +dotnet test Lab6test/Lab6test.csproj --filter "FullyQualifiedName~GreenTest.Test01" +``` + +### Run all tests (no filter) +```bash +dotnet test Lab6test/Lab6test.csproj --configuration Debug +``` + +--- + +## CI/CD Pipeline (`.github/workflows/Tests_runner.yml`) + +- **Triggers:** `push` (non-main branches), `pull_request_target`, `workflow_dispatch`, `issue_comment` +- **Runner:** `windows-latest` +- **Protection:** PRs targeting `main` are blocked outright +- **Cascade strategy:** The workflow tries test classes in order — `Purple → Blue → Green → White` — and stops at the first passing class. This means GreenTest must fully pass to count as a successful run. +- **Artifacts:** TRX test result files are uploaded after every run + +--- + +## Task Descriptions (Green.cs) + +| Method | Signature | Description | +|----------|----------------------------------------------------|-------------| +| `Task1` | `void Task1(ref int[] A, ref int[] B)` | Delete max element from each array, then combine A and B into A; B becomes A-without-max | +| `Task2` | `void Task2(int[,] matrix, int[] array)` | In each row, replace the max element with `array[i]` if `array[i]` is larger | +| `Task3` | `void Task3(int[,] matrix)` | Find global max in square matrix; swap its column with the main diagonal | +| `Task4` | `void Task4(ref int[,] matrix)` | Remove all rows that contain at least one zero | +| `Task5` | `int[] Task5(int[,] matrix)` | For each row of a square matrix, find the minimum of elements from the diagonal position onward | +| `Task6` | `int[] Task6(int[,] A, int[,] B)` | Return combined array of column-wise positive sums from matrix A then matrix B | +| `Task7` | `void Task7(int[,] matrix, Sorting sort)` | Apply the given `Sorting` delegate to every row of the matrix | +| `Task8` | `int Task8(double[] A, double[] B)` | Compare triangle areas (sides given); return 1 if A >= B, 2 if B > A (Heron's formula) | +| `Task9` | `void Task9(int[,] matrix, Action sorter)` | Apply `sorter` to every even-indexed row (0, 2, 4, …) | +| `Task10` | `double Task10(int[][] array, Func func)` | Apply `func` to the jagged array and return the result | + +### Key Helper Methods + +| Method | Purpose | +|--------|---------| +| `DeleteMaxElement(ref int[] array)` | Remove the first occurrence of the maximum value | +| `CombineArrays(int[] A, int[] B)` | Concatenate two arrays | +| `FindMaxInRow(int[,], int row, out int col)` | Returns max value and its column index | +| `FindMax(int[,], out int row, out int col)` | Global max with position | +| `SwapColWithDiagonal(int[,], int col)` | Swap column `col` with main diagonal elements | +| `RemoveRow(ref int[,], int row)` | Remove a single row from a 2D array | +| `SumPositiveElementsInColumns(int[,])` | Per-column sum of positive values | +| `SortEndAscending/Descending(int[])` | Sort elements after the max element position | +| `GeronArea(double a, b, c)` | Triangle area via Heron's formula; returns 0 for degenerate triangles | +| `ReplaceRow(int[,], int row, int[])` | Overwrite one row in a 2D matrix | +| `CountZeroSum(int[][])` | Count jagged rows whose element sum is zero | +| `FindMedian(int[][])` | Median of all elements across a jagged array | +| `CountLargeElements(int[][])` | Count elements greater than their row's average | + +--- + +## Code Conventions + +### Naming +- Classes and methods: **PascalCase** (`Green`, `Task1`, `DeleteMaxElement`) +- Local variables: **camelCase** (`max`, `idx`, `rows`, `cols`) +- Matrix parameters: uppercase single letters (`A`, `B`) +- Loop counters: single letters (`i`, `j`, `k`, `r`, `w`) + +### Style +- No LINQ — use explicit loops +- Return `null` (or early-return `void`) for null/invalid inputs rather than throwing exceptions +- Use `out` parameters for multiple return values from helpers +- `// code here` and `// end` comments mark the implementation region in task methods +- No explicit access modifiers on class members (implicitly `internal`/package-private) + +### Testing Patterns +- Test class: `GreenTest` (sealed, `[TestClass]`) +- Float comparison epsilon: `const double E = 0.0001` +- AAA pattern: Arrange / Act / Assert +- Fixtures provided by `Data` class via `GetMatrixes()` and `GetArrayArrays()` +- Test data is cloned in `Data` — mutations during tests do not affect other tests + +--- + +## Development Branch + +Work on branch: **`claude/add-claude-documentation-VG80N`** + +Push with: +```bash +git push -u origin claude/add-claude-documentation-VG80N +``` + +Do **not** push to `main` — the CI pipeline will reject PRs targeting main. + +--- + +## Common Pitfalls + +1. **`Task4` uses `ref int[,]`** — the method must reassign the parameter (`matrix = res`), not just mutate in place. +2. **`Task3` requires a square matrix** (`n == m`); return early otherwise. +3. **`Task8` tie-breaking** — when both triangle areas are equal, return `1` (first triangle wins). +4. **`Task9` sorts only even-indexed rows** (0-based: rows 0, 2, 4, …). +5. **`GeronArea` returns `0`** for degenerate triangles (any side ≤ 0 or triangle inequality fails). +6. **`Task10` delegates all logic to `func`** — the method is a thin pass-through. +7. **RootNamespace mismatch** — `Lab6test.csproj` sets `RootNamespace` to `Lab1_test`, but the actual namespace in source files is `Lab6test`. Do not change this.