public static int damerauDist(int color1, int color2) {

        String compOne = color1+"";
        String compTwo = color2+"";

        int res = -1;
        int INF = compOne.length() + compTwo.length();
 
        int[][] matrix = new int[compOne.length()+1][compTwo.length()+1];
 
        for (int i = 0; i < compOne.length(); i++)
        {
            matrix[i+1][1] = i;
            matrix[i+1][0] = INF;
        }
 
        for (int i = 0; i < compTwo.length(); i++)
        {
            matrix[1][i+1] = i;
            matrix[0][i+1] = INF;
        }
 
        int[] DA = new int[24];
 
        for (int i = 0; i < 24; i++)
        {
            DA[i] = 0;
        }
 
        for (int i = 1; i < compOne.length(); i++)
        {
            int db = 0;
 
            for (int j = 1; j < compTwo.length(); j++)
            {
 
                int i1 = DA[compTwo.indexOf(compTwo.charAt(j-1))];
                int j1 = db;
                int d = ((compOne.charAt(i-1)==compTwo.charAt(j-1))?0:1);
                if (d == 0) db = j;
 
                matrix[i+1][j+1] = Math.min(Math.min(matrix[i][j]+d, matrix[i+1][j]+1),Math.min(matrix[i][j+1]+1,matrix[i1][j1]+(i - i1-1)+1+(j-j1-1)));
            }
            DA[compOne.indexOf(compOne.charAt(i-1))] = i;
        }
         
        return matrix[compOne.length()][compTwo.length()];
    }