Question to all you nerds
Question to all you nerds : -
(Not an interview question)
Need a math formula to determine a result number based on provided input (Row number: a, Column number: b, Total Rows: p, Total column: q). let me explain the scenario :
Scenario 1:
01 02 06 07 14 15 22 23 30 31 38 39
03 05 08 13 16 21 24 29 32 37 40 45
04 09 12 17 20 25 28 33 36 41 44 46
10 11 18 19 26 27 34 35 42 43 47
For the above given matrix. If you notice numbers are ordered diagonally down and then diagonally upwards.
If Row number is given as 1 and column 1 for total rows 4 and column 12 I should get value 1
If Row number is given as 2 and column 3 for total rows 4 and column 12 I should get value 8
If Row number is given as 3 and column 12 for total rows 4 and column 12 I should get value 46
Formula should be generic to derive any number provided row and col.
Scenario 2:
Similar to above if number of rows increases from 4-5 still the formula should be able to derive the number correctly provide those row/col/total row and total columns.
01 02 06 07 15 16 25 26 35
03 05 08 14 17 24 27 34
04 09 13 18 23 28 33
10 12 19 22 29 32
11 20 21 30 31
Please help. Thanks in advance