Solution (By Warut Suksompong). The answer is 6⌊4n⌋+n−4⌊4n⌋=n+2⌊4n⌋.
For n=1 the answer is clearly 1, since there is only one configuration other than the initial one, and that configuration takes 1 step to get to. From now on we will consider n≥2.
Note that there are 3n possible operations in total, since we can select 3n lines to perform an operation on (n lines parallel to each side of the triangle.) Performing an operation twice on the same line is equivalent to doing nothing. Hence, we will describe any combination of operations as a triple of n-tuples ((a1,a2,…,an),(b1,b2,…,bn),(c1,c2,…,cn)), where each element ai,bi,ci is either 0 or 1 (0 means no operation, 1 means the opposite), each tuple of the triple denotes operating on a line parallel to one of the sides, and the indices denote the number of marks in the row of operation. Let A denote the set of all such 3n-tuples, so that ∣A∣=23n.
Let B denote the set of all admissible configurations. Let N=2n(n+1). We will describe each element of B by an N-tuple (z1,z2,…,zN), where zi=0 if mark i is black and zi=1 otherwise.
For each element a∈A, let b=f(a) be the element of B that is the result of applying the operations in a. Then f(a+a′)=f(a)+f(a′) for all a,a′∈A, where addition is considered in modulo 2. Let K be the set of all a∈A such that f(a) is the all-black configuration. The following eight elements are easily seen to be in K.
* ((0,0,…,0),(0,0,…,0),(0,0,…,0))=id
* ((0,0,…,0),(1,1,…,1),(1,1,…,1))=x
* ((1,1,…,1),(1,1,…,1),(0,0,…,0))=y
* ((1,1,…,1),(0,0,…,0),(1,1,…,1))=x+y
* ((0,1,0,1,…),(0,1,0,1,…),(0,1,0,1,…))=z
* ((0,1,0,1,…),(1,0,1,0,…),(1,0,1,0,…))=x+z
* ((1,0,1,0,…),(1,0,1,0,…),(0,1,0,1,…))=y+z
* ((1,0,1,0,…),(0,1,0,1,…),(1,0,1,0,…))=x+y+z
We will show that they are the only elements of K.
Suppose L=((a1,a2,…,an),(b1,b2,…,bn),(c1,c2,…,cn)) is in K. For i+j+k=2n+1, there is a unique mark contained in a row of length i in the a direction, a row of length j in the b direction, and a row of length k in the c direction. Operations ai, bj, and ck are the only operations affecting the mark, so ai+bj+ck=0. By adding one or both of x and y if necessary, we will assume that bn=cn=0. Since a2+bn−1+cn=a2+bn+cn−1=0, we have that bn−1=cn−1. We now have two cases.
a. First, suppose that bn−1=cn−1=0. Then from a3+bn−2+cn=a3+bn−1+cn−1=a3+bn+cn−2, we have that bn−2=cn−2=0. Continuing in this manner (considering equalities with a4,a5,…), we find that all the bi's and ci's are 0, from which we deduce that L=id.
b. Second, suppose that bn−1=cn−1=1. Then from a3+bn−2+cn=a3+bn−1+cn−1=a3+bn+cn−2, we have that bn−2=cn−2=0. Continuing in this manner (considering equalities with a4,a5,…), we find that (b1,b2,…,bn)=(c1,c2,…,cn)=(…,1,0,1,0), from which we deduce that either L=z or L=x+z.
Hence L is one of the eight elements listed above. It follows that the 23n elements of A form 23n−3 sets consisting of elements differing by an element of K. Each a∈A corresponds to an element of B which is the result of applying the operations in a. For each element a∈A, let x1 be the number of ai with odd indices which are equal to 1, and let x2 be the number of ai with even indices which are equal to 1. Define y1,y2,z1, and z2 similarly for the bi's and ci's. Note that for each choice of (x1,x2,y1,y2,z1,z2), there is at least one element of A which corresponds to this choice.
Let T(a) be the minimum value of T over the set containing a. The maximum of this value over all the sets is the desired answer. For an element a∈A with minimal value of T in its set, adding an element of K to a must increase the value of T. Conversely if adding any element of K to a decreases T, then a has the minimal value of T within its set. Applying this observation for x,y,x+y,z,x+z,y+z,x+y+z∈K, we see that a∈A has the minimal value of T within its set if and only if the following inequalities hold.
(a) x1+x2+y1+y2≤n
(b) x1+x2+z1+z2≤n
(c) y1+y2+z1+z2≤n
(d) x2+y2+z2≤⌊23⌊n/2⌋⌋=V
(e) x1+y1+z2≤⌊22⌊n/2⌋+⌊n/2⌋⌋=W
(f)x2+y1+z1≤⌊22⌊n/2⌋+⌊n/2⌋⌋=W
(g)x1+y2+z1≤⌊22⌊n/2⌋+⌊n/2⌋⌋=W
Adding the last four inequalities and dividing by 4, we obtain
T(a)≤⌊2V+3W⌋.
We analyze this in four separate cases:
a. n=4k. Then V=W=3k, and so T(a)≤6k, with equality for x1=x2=y1=y2=z1=z2=k.
b. n=4k+1. Then V=3k and W=3k+1, and so T(a)≤6k+1 with equality for x1=x2=y1=y2=z2=k and z1=k+1.
c. n=4k+2. Then V=3k+1 and W=3k+1, and so T(a)≤6k+2 with equality for x1=x2=y1=y2=k and z1=z2=k+1.
d. n=4k+3. Then V=3k+1 and W=3k+2, and so T(a)≤6k+3 with equality for x1=x2=y2=k and y1=z1=z2=k+1.
In each case, observe that T(a)≤n+2⌊4n⌋ and that equality is attained for some configuration in A, hence the maximum value of T(a) is as claimed, concluding our proof.