You are given a 3 × 3 grid which contains integers. Some of the 9 elements in the grid will have a value already, and the remaining elements will be unspecified. Your task is to determine values for the unspecified elements such that each row, when read from left-to-right is an arithmetic sequence, and that each column, when read from the top-down, is an arithmetic sequence.
Recall that an arithmetic sequence of length three is a sequence of integers of the form a,a+d,a+2d
for integer values of a and d. Note that d may be any integer, including zero or a negative integer.
Sample Input 1
8 9 10 16 X 20 24 X 30
Output for Sample Input 1
8 9 10 16 18 20 24 27 30
Sample Input 2
14 X X X X 18 X 16 X
Possible Output for Sample Input 2
14 20 26 18 18 18 22 16 10
For the first sample input I understand how I could make a program to solve it, but I am unsure about the second one.