private static void printResult(char[][] arr) {
        int min = 10;
        int xPos = 0;
        int yPos = 0;

        for (int i = 0; i < arr.length; i++) {
            yPos = arr[i].length;
            for (int j = 0; j < arr[i].length; j++) {
                if (arr[i][j] == 'X') xPos = j;
                if (arr[i][j] == 'Y' && j < yPos) yPos = j;
            }
            int temp = yPos - xPos - 1;
            if (temp < min) {
                min = temp;
            }
        }

        out.println(min);
    }