Company: codesignal
Difficulty: medium
Imagine you are an avid gardener planning the layout of a large garden. You have a 2D grid where each cell represents a plot. A value of 1 means a flower is planted in that plot and a value of 0 means the plot is empty. An "L" shaped flower arrangement is defined as follows: A collection of 3 plots is an L shaped arrangement if one of its plots is in the same row as a second plot and in the same column as the third plot. The 3 plots do not have to be next to each other. All three plots must contain flowers (value 1 ). Two arrangements are the same if they consist of the same set of three plots, so each set of three plots is counted at most once. Grid generation The grid is not given explicitly. It is generated from four integers row , col , magicalNumber and mod using the formula grid[i][j] = ((i + j + magicalNumber) % mod) % 2 where i ranges over 0 .. row-1 and j ranges over 0 .. col-1 , and % is the modulus operation. Input format A single line containing four space-separated integer