Prog Exercises
1 Cutting Up a Chess Board into L-shapes
On a chessboard of size 8 x 8, the square at position (x, y) is cut off. Write a program, which will cut the rest of the chessboard into L-shaped fragments (3 adjacent squares). Example: Cut-off square at (1, 4) should result in the figure. [Found on Quora.com 2016]
2 Tomohiko Sakamoto's Algorithm
Apparently the following computes the day of week from any given date.
int dow(int y, int m, int d) { static int t[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4}; y -= m < 3; return (y + y/4 - y/100 + y/400 + t[m-1] + d) % 7; }
2.1 Exercise
- Specify it.
- Explain it. Including "static".
- Is it kosher to alter y?