The puzzle came first:
The answer followed:
Don’t click on the answer if you don’t want it spoiled. You have been warned.
I don’t believe that posting the answer ruins anything. Nobody else can claim this as their own because they would still have to explain how they achieved this result.
Believe me when I say that I can go into excruciating details. :)
Also, in my case, it was an excellent way to practice Erlang. Nothing beats solving a “real” problem to imprint a programming language in your head.