import java.util.*;
import java.math.*;
class TopcoderSolution {
public static void main(String[] args) {
PenguinTiles obj = new PenguinTiles();
System.out.println(
// obj.numPairs(numbers)
obj.minMoves(null
));
}
}
// change to public before submit
public class PenguinTiles {
public int minMoves(String[] tiles) {
int xi = -1;
int xj = -1;
for (int i = 0; i < tiles.length; i++) {
for (int j = 0; j < tiles[i].length(); j++) {
if (tiles[i].charAt(j) == '.') {
xi = i;
xj = j;
break;
}
}
if (xi >= 0)
break;
}
if (xi == tiles.length - 1 && xj == tiles[0].length() - 1)
return 0;
if (xi == tiles.length - 1 || xj == tiles[0].length() - 1)
return 1;
return 2;
}
}
No comments:
Post a Comment