Solution to Vietnamese pesky snake in #perl

I got a link to the Vietnamese Pesky Snake math problem from my wife. (http://m.db.no/2015/05/21/nyheter/utenriks/matematikk/oppgave/39292707/) And as a programmer, I couldn’t really sit there and solve it with my bare hands. Ok, I admit it’s fun to solve math problems, but this was very much looking like a problem with more than one solution, and I needed to know for sure 🙂