number of paths 2d array
<p>I have to find the shortest path from one index to the other.</p>

<p>In order to progress a index the index must be a "neighbor" with same value inside the index as the one next to it. I have to create a function that calculates all possible paths recursively and then puts all in a matrix.</p>

<p>My thoughts so far where to use the flood fill algorithm and somehow count each path.</p>

<p>ok so ive been sitting here quite a while trying to figure out how to do this and so far I came with this idea: create a duplicate array that in each index will show me the distance from my initial node. im not sure if I am doing this correctly so a little help is needed, this is what I wrote:</p>

<pre><code>public static int[][] createdistancematrix(int[][] map, int i, int j) {
    int[][] temp = new int[map.length][map[0].length];
    map[i][j] = 0;
    int count = 0;
    filldistance(temp, i, j,count);

    return temp;
}

public static int[][] filldistance(int[][] temp, int i, int j,int count) {
    if ((i&lt;temp.length) &amp;&amp; (i&gt;=0) &amp;&amp; (j&lt;temp.length) &amp;&amp; (j&gt;=0)) {

        temp[i][j] = count;
        count++;

        //recursive call for north east west south.

        filldistance(temp, i-1,j, count);
        filldistance(temp, i+1,j, count);
        filldistance(temp, i,j-1, count);
        filldistance(temp, i,j+1, count);
    }
    return temp;
}
</code></pre>
