We want to test the efficiency of new sheet metal forming process. After forming we measure the deviation from the intended thickness.
The raw data can be visualised as a square grid of measurements ranging from 0 (correct thickness) to 5 (high deviation from correct thickness).
We want to find large areas of high deviation from the correct thickness. To do so, We calculate a score for each location in the grid. The score is determined by adding the location's own deviation,
to its surrounding deviations.
For Example, in a grid:
4 | 2 | 3 | 2
0 | 1 | 2 | 2
1 | 3 | 0 | 2
2 | 0 | 1 | 5
The score for location `(1,1)` is follows:
score(1,1) = 4 + 2 + 3 + 0 + 1 + 2 + 1 + 3 + 0 = 16
When dealing with locations around the edge of the grid the score
should ignore values outside the grid. For instance the score of
location `(0, 0)` is as follows:
4 | 2 | 3 | 2
0 | 1 | 2 | 2
1 | 3 | 0 | 2
2 | 0 | 1 | 5
score(0,0) = 4 + 2 + 0 + 1 = 7
Write a function:
class Solution { public string solution (int T, int N, int[ ] V); }
that, given an integer `T`, an integer `N` and a zero-indexed array `V`
consisting of `N*N` integers, return a list of the `T` highest scores and
their locations.
Each location and score should be formatted:
(x, y, score)
Where `(x,y)` is the zero-indexed vector from the top-left of the grid.
The list should be returned as a string:
(x1, y1, score1) (x2, y2, score2) (x3, y3, score3)
If there are multiple locations with the same score, prefer locations
to the top-left e.g. `(1, 0 ,20)(2, 0, 20)(1, 1 ,20)`
The inputs asking for the top1 measurement in the grid:
4 | 2 | 3 | 2
0 | 1 | 2 | 2
1 | 3 | 0 | 2
2 | 0 | 1 | 5
Would be:
T = 1
N = 4
V = [4, 2, 3, 2, 0, 1, 2, 2, 1, 3, 0, 2, 2, 0, 1, 5]
What I have tried:
I didn't understand properly what exactly the output is. I am not good at statistics. Can anyone help me to find the solution? Thanks