Numeric Keypad

Here is the question.
Given the mobile numeric keypad. You can only press buttons that are up, left, right or down to the current button. You are not allowed to press bottom row corner buttons (i.e. * and # ). You have to find the count of different numbers that can be generated by pressing N number of buttons.

Here is my code. I am getting wrong ans for n=3 . the ans is 138 and i am getting 112. Please help me to figure out what i have missed in my logic.

Share a link to your submission or use pastebin/ideone. The link you shared is directing to Codechef IDE. You can even paste your code here in between a pair of 3 back ticks.

Thanks for the reminding. Here is the code.