I am trying to solve this problem: https://projecteuler.net/problem=11 However, this part confuses me:
What is the greatest product of four adjacent numbers in the same direction (up, down, left, right, or diagonally) in the 20×20 grid?
what does in the same direction and up, down, left, right or diagonally mean?
Is it just me or is the language vague here?
this is what I have tried so far:
long int prod{0}, n{20};
for(int i{0}; i <= n; i++) {
for(int j{0}; j <= n; j++) {
long int a{grid[i][j]}, b{grid[i+1][j+1]}, c{grid[i+2][j+2]}, d{grid[i+3][j+3]};
if(prod < (a * b * c * d))
prod = a * b * c * d;
}
}
return prod;
With this function I satisfy the first demand but up down left right or diagonally? what does or mean there?