At skirve et algoritme til denne
import java.io.*;import java.util.*;
public class TreasureC {
// Should return the total number of reachable treasures.
public int countReachableTreasures(int N, char[][] map) {
// Implement this
}
// ##################################################
// # You do not need to modify anything below here. #
// ##################################################
public static void main(String[] args) throws IOException {
new TreasureC().run();
}
private void run() throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(in.readLine());
char[][] map = new char[N][N];
for (int i = 0; i < N; i++) {
String line = in.readLine();
for (int j = 0; j < N; j++) {
map[i][j] = line.charAt(j);
}
}
System.out.println(countReachableTreasures(N, map));
}
}
Der skal implementeres den øverste metode til finde direkte indgange til antal $ i
########
I # #
# # ## #
# # #$#
# ###
#### # #
#$ #$#
########
hvordan ?