Need an help on how to approach and solve this problem with solution code. Thank you all in advance.
Triangular Assortment
Given a triangular assortment of size N where the total number of rows is N, which is always
even. The triangles are numbered starting with the triangle in the first row, and increasing lef
t to right and top to bottom. An example of such an arrangement with N=6 is given below.

The task is to find minimum distance d from a given starting triangle (s) to all the other trian
gles. Two triangles are called adjacent if they have a common edge. From a triangle, you can
only go to an adjacent triangle. Distance between two triangles is the minimum number of e
dges to be crossed to reach the destination triangle from the starting triangle. The distance b
etween any triangle to its adjacent triangle is 1 unit.
Input:
Two space separated Integer variables N & S, denoting the size of the
triangular assortment (N) and number assigned to the starting triangle
(S) respectively.
Output:
Space separated distances d to all the triangles increasingly ordered
by the triangle number.
Constraints:
1 <= N/2 <= 10