Monday, June 02, 2008

One more MGPT

I had one more MGPT(Machine Graded Programming Test), on 24th May. Below, is what I can remember from the problem.

  1. Input is two integers
  2. First integer is to have a 2D array of that size
  3. second integer, to find the numbers by that that number is surrounded
    e.g. I input 11 and 11 So I will have a circular array as shown below:

111 112 113 114 115 116 117 118 119 120 121
110   73   74   75   76   77   78   79   80   81   82
109   72   43   44   45   46   47   48   49   50   83
108   71   42   21   22   23   24   25   26   51   84
107   70   41   20     7     8     9   10   27   52   85
106   69   40   19     6     1     2   11   28   53   86
105   68   39   18     5     4     3   12   29   54   87
104   67   38   17   16   15   14   13   30   55   88
103   66   37   36   35   34   33   32   31   56   89
102   65   64   63   62   61   60   59   58   57   90
101 100   99   98   97   96   95   94   93   92   91

and second input say 11 then my output should be

9 10 27

2 11 28

3 12 29

A number can have a minimum of 3 surrounded and a max of 8 numbers. First number will be an Odd number only (to have a middle starting position).

Will be posting my solution, later on

 

Second Problem

Its like a social network. e.g.

A -> B (A is connected to B)

B -> C (B is connected to C)

then C is indirectly connected to A. In middle there can be many other also. So to reach from A to C, there is one person. Input will be

A C and output should go like, the mediator name and number of hops to pass to reach the required person.