Here is how Mitchell explains the solution:
"There are 2 ways to look at it. The first way is: to get a peg out, the one before it must be out, and the rest before that must be in. For example, if you want to get peg #5 out, peg #4 has to be out, and peg #1, #2, and #3 must be in. The other way is: every 2nd peg is peg #1, every 4th peg is peg #2, every 8th peg is peg #3, every 16th peg is peg #4, etc.
The sequence is 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 6 1 2 1 etc. You should be able to figure the rest out yourself. To get the pegs in, it is just the reverse of the sequence.
If you have any questions about my solution, please email me at stern.mitchell[at]gmail[dot]com"
Harris