MathOverflow is a question and answer site for professional mathematicians. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I hope this doesn't fall under the "not interesting to mathemeticians" category.

I'm attempting to solve one of the facebook engineering puzzles. Essentially, the idea is that two dancers do a dance-off with a predefined number of moves. For every turn, the dancer has to begin with the last move the other dancer used. Every time a combination of moves is used, both that combination and its reverse are excluded. For instance, if you do (1, 2), then neither dancer can do (1, 2) or (2, 1). Dancers may repeat moves. The dancers will dance optimally, and the battle is over when there are no more moves left.

My first thought when trying to solve this went like this: the dancers are essentially building a B(n, 2) de Bruijn sequence. The length of the sequence should be n^2. I figured that if the number of turns is odd, then you win. If the number of turns is even, then they win. Thus since n^2 will be odd if n is odd, and n^2 will be even if n is even, all I did was check to see if it was odd or even to determine the winner. This wasn't the correct answer.

So here's my current way of thinking: the dancers are going through a de Bruijn graph. For every turn, two vertices are considered visited unless it is a duplicate (like (1, 1) or (2,2)). Therefore, the number of turns available would be 2^n - n. But this just seems like a more complex way to do the same thing as I was doing above. After all 2^n will always yield a positive, so this will yield an even if n is even and an odd if n is odd.

I don't really want to ask anyone to solve this for me (I want to solve it on my own). But can someone at least tell me if I'm on the right path, or is there something fundamental I'm missing?

share|cite|improve this question

Your original answer would have been correct had the dancers had been simply searching for an optimal path through the movements to traverse as much of the graph as possible. You need to account for the dancers attempting to win.

share|cite|improve this answer
I suppose I should have spent a little bit more time thinking about what an "optimal" strategy really is. :-) – Jason Baker Oct 19 '09 at 20:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.