This is about the Google foo.bar Gearing Up for Destruction challenge - 2nd of 2 challenges on Level 2. It was pretty interesting and I got through most of it without looking for answers. I did get stuck on 2 failing tests so I finally caved. I didn't copy my solution though, just got an insight from the solution that @CBarraford posted here: https://gist.github.com/1lann/be45311db1bd8cbbe6650b0a3e9d1977, which was a more brute-force trial-and-error solution.
Here's the math I worked out for this problem:
Given:
n pegs, numbered from 1 to n
Let:
d(n) - the distance between peg[n] and peg[n+1]