#include <stdio.h>
#include <stdlib.h>

#define START 8
#define GOAL 1
#define ROUTE 100
#define END -1
int maze[6][6];
const int y_goal = 5, x_goal =2;
int route[ROUTE][2];
int rp = 0;
int solvemaze(int y, int x) {
	static int success = 0;
	if(y==y_goal && x==x_goal)success == GOAL;
	maze[y][x] = 'T';
	if(!success && maze[y-1][x] == '0'){solvemaze(y-1, x);}
	if(!success && maze[y][x+1] == '0'){solvemaze(y, x+1); }
	if(!success && maze[y][x-1] == '0'){solvemaze(y, x-1); }
	if(!success && maze[y+1][x] == '0'){solvemaze(y+1, x); }
	if(success) {
		route[rp][0] = y;
		route[rp][1] = x;
		rp++;
	}
	return success;
}

void maze_print() {
	int i, j;
	for(i=0; i<6; i++) {
		for(j=0; j<6;j++) {
			printf("%d", maze[j][i]);
		}
		printf("\n");
	}
}

int main() {
	int i;
	maze_print(); printf("\n");
	solvemaze(1,1);
	maze_print(); printf("\n");
	for(i=rp; i; i--) {
		printf("%d.", route[i-1][0]);
		printf("%d", route[i-1][1]);
	}
	putchar('\n');
	return 0;
}
