Was told there were follow-up questions but could not finish the first part in time. Struggled with it.
Square Terminal is a credit card terminal for payments. The company is looking to create a new version of the Square Terminal. During the screen selection process, you are asked to print a testing pattern on the screens on the Square Terminal.
For simplicity's sake, you are told that the requirements of this screen is a NxN pixel square (no pun intended), 8 bit depth and only supports grayscale (0,255).
In order to test the quality and functionality of the screen, you must create a black and white vertical stripe pattern with each stripe being M wide. The first stripe will be black.
1) Given a pattern of size N and a stripe width of M, generate the black and white stripe pattern.
Sample Test Cases (format: size N, width M):
Test1 Input: 2,1
Test1 Output:
0 255
0 255
Test2 Input: 4, 2
Test2 Output:
0 0 255 255
0 0 255 255
0 0 255 255
0 0 255 255
Test3 Input: 7, 1
Test3 Output:
0 255 0 255 0 255 0
0 255 0 255 0 255 0
0 255 0 255 0 255 0
0 255 0 255 0 255 0
0 255 0 255 0 255 0
0 255 0 255 0 255 0
0 255 0 255 0 255 0
I'm sure it is a result of not getting far enough but I imagine we also need to handle the scenario where we have an NxN square where N is an odd number (ie. 5x5 size) and then M is also odd number(ie. 3 width) like following Test case Test Input 5,3. It might be inferrable from the question but I wasn't able to solve it.