problem 42 solved after consulting the answer

The answer on fisherlei.blogspot.com is elegant!