Techgig gaming console

Techgig gaming console

A new type of computer game is launched in the market, which requires a special type of gaming console. Makers of the games has made a new generation gaming console with a very unique remote. The keys/Layout of remote is as shown below

This remote contains 12 keys with 2 nonfunctional keys. Each functional key has been given a unique label as shown above.

The Computer game for this console has N levels. There are certain moves in the game which are controlled using the remote. The keys for each moves changes with the number of levels i.e. number of keys for an operation is dependent on the game level, for example for third level, single move require three key [you have to press three keys in sequence for a move in third level]. A player can only press keys that are left, right, up or down to the current key and he is not allowed to press bottom row corner keys.

Suppose a player is at level 2. According to the rules he has to press 2 keys for a move (the number of keys is equal to the level). The possible Moves key will be ‘HH’, ‘HI’, ‘HG’, ‘HE’, ‘HJ’, ‘IF’ ,.. Etc

1. If a Move start from ‘J’, possible keys are ‘JJ’, ‘JH’ (count 2)

2. If a Move start from ‘H’, possible keys are ‘HH’, ‘HI’, ‘HG’, ‘HE’, ‘HJ’ (count 5)

3. If a Move start from ‘I’, possible keys are ‘II’, ‘IH’, ‘IF’ (count 3)



So for level 2, number of possible moves would be 36.

If a player is at level N, you have to find the total possible number of moves for that level.

Input/Output Specifications

Input Specifications:

Input is an integer N, which is level of the game

Output Specifications:

Output is an integer M, which is the total possible number of Moves



Input: 2

Output: 36

Solution in C# using dynamic programming:

using System;

using    System.Collections.Generic;

    public static int combinationCounts(int input1)


                        //Write code here

                        System.Collections.Generic.SortedDictionary<string,char[]> myDictionary;

                        myDictionary = new SortedDictionary<string, char[]> { { “A”, new char[] { ‘A’, ‘B’,’D’ } },

                        { “B”, new char[] { ‘A’, ‘B’,’C’,’E’ } },

                        { “C”, new char[] { ‘F’, ‘B’,’C’ } },

                        { “D”, new char[] { ‘A’, ‘G’,’D’,’E’ }} ,

                        { “E”, new char[] { ‘F’, ‘B’,’D’,’E’,’H’ }} ,

                        { “F”, new char[] { ‘I’, ‘F’,’C’,’E’ }} ,

                        { “G”, new char[] { ‘D’, ‘G’,’H’ }} ,

                        { “H”, new char[] { ‘G’, ‘H’,’I’, ‘E’,’J’} } ,

                        { “I”, new char[] { ‘H’, ‘I’,’F’ }} ,

                        { “J”, new char[] { ‘H’, ‘J’ }}};

                         int[,] max = new int[input1,10];

        for(int i=0 ; i < 10 ; i++)




        for(int i=1 ;i < input1;i++ )


            int j=0;

            foreach (KeyValuePair<string, char[]> p in myDictionary)


                int count=0;

                char[] temp =p.Value;

                for(int k=0 ; k < temp.Length;k++)


                    count+=max[i-1,temp[k] – ‘A’];






        int sum=0;

        for(int i=0;i<10;i++)


         return sum;