A counting problem

Suppose there are three kind of different balls $A,B,C$ whose numbers are $i,j,k$ respectively. Let these $i+j+k$ balls be in line.

Please find the closed form of even arrangement, where an arrangement is called even if there are even items such that the ball at this item is different from its previous one.

-
I suggest math.stackexchange.com for questions like this. MathOverflow is for research-level questions. – David Roberts Nov 4 2010 at 3:23
gondolf, this looks like a problem at the level of an undergrad intro combinatorics class. Maybe there's more to it than that - can you convince us? Say, show us that you've tried some pretty sophisticated approaches that didn't work? Or that you have some reason for wanting the answer unrelated to a class you're enrolled in? – Gerry Myerson Nov 4 2010 at 3:58
I vote to reopen. The problem is not trivial. Perhaps Andres, Ryan, Andrey, Gjerji will jointly find a solution, post it here, and then close the question again? I think that would be a fair decision. – Mark Sapir Nov 4 2010 at 8:25
I'd like to see more effort go into the statement of the question, if it's to be reopened. – Gerry Myerson Nov 4 2010 at 13:16
This problem yields to intelligent use of standard generating function methods. Let AA[x,y,z] be the generating function for sequences of balls that start and end with A, where x, y and z keep track of the number of balls of each type, and where each sequence is weighted by (-1)^{number of consecutive balls of different types}. Define AB[x,y,z], AC[x,y,z], ..., CC[x,y,z] likewise. It is simple to write down linear relations between these 9 generating functions, and hence to compute them. Then extracting the answer is straightforward. Hint: matrices make life easy. – David Speyer Nov 5 2010 at 14:28