• No recursion?

Question related to mission Univocalic Davasaan

 

Hi all! I have solved this task using recursion + few lambdas but got not so many points. Could anybody tell me what technique should I use to make my code shorter? Will binary shift operators (<< or >>) help me?