Well Filiprei, I really don't know what you're trying to do?
You copied the line for calculating horizontally (and change + to -) and claim it is vertically?
line 3 and 18 produce the same result. Just that line 18 will produce less.
you may write all results for the different calculation in different files. Then compare the results. if the results of one calculation is equal or a subset of the other calculation you did something wrong.
Lets reduce complexity (to 2):
1 2 3 4
|
arr[i + 0][o + 0] * arr[i + 0][o + 1]
arr[i + 0][o + 0] * arr[i + 1][o + 1]
arr[i + 0][o + 3] * arr[i + 1][o + 2]
arr[i + 0][o + 0] * arr[i + 1][o + 0]
|
The important thing is the the content of [] is in fact different. The problem is to find any existing combination.
The nature of multiplication is that e.g.
arr[i][o] * arr[i][o + 1]
produces the same result as
arr[i][o] * arr[i][o - 1]
That's not a true difference!
I made a little mistake on line 11:
const long long value = arr[i][o + 3] * arr[i + 1][o + 3] * arr[i + 2][o + 1] * arr[i + 3][o] // Diagonally: /
Corrected:
const long long value = arr[i][o + 3] * arr[i + 1][o + 2] * arr[i + 2][o + 1] * arr[i + 3][o] // Diagonally: /