14
2
Given a maze on stdin and an entry point, write a program that prints a path to the exit on stdout. Any path is acceptable, as long as your program does not generate the trivial path (passing through every point in the maze) for every maze.
In the input, walls are marked by a #
and the entry point by a @
. You may use any characters to draw the maze and the path in the output, as long as they're all distinct.
You may assume that:
- The entry and exit points are on the edges of the input
- Every line of the input has the same length
- The maze is solvable and has no cycles
- There is only one exit point
Shortest solution by (Unicode) character count wins.
Examples
(note that the inputs are padded with spaces)
####
# #
@ #####
# #
#
#######
####
# #
@*#####
#* #
#******
#######
### ###################
### # #
## ######### # #
# ##### #
############### #@##
###*###################
###*********#*********#
## *#########* # *#
# *********** #####**#
############### #@##
Can I add a character for the endpoint, also? It would make it much easier for my program to know when to end. – Peter Olson – 2011-04-25T13:38:56.423
@Peter Of The Corn: Sure. You don't have to use the same character to draw the entire path, it just has to be distinguishable from the rest of the output. – Lowjacker – 2011-04-25T13:47:39.557