UVa 227 - Puzzle

227 - Puzzle
227-"Puzzle"

Summary
You're given a 5*5 puzzle of characters between 'A' and 'Z' ,inclusively. and only one space among the characters that indicates the blank space on a normal puzzle ,you're given after that a list of orders (ending in a '0' zero character) that you should implement on that puzzle ,if the orders cannot be done(i.e out of bounds) output that there is no final configurations, otherwise output the final configuration with a space between every character and a new line between outputs.

Gotchas
The judge expects no blank lines at the end of the output but expects a new line. And it doesn't expect a space after the last character of each line of a configurable puzzle.

Implementations
Make a 2-D array (or better, an array of strings)and take the input of the puzzle ,you can search for the space while taking the input and save the $$O(N^2)$$ caused by searching afterwards, then you can implement a do while to take the orders while the last character of the string is not a 0 then you can apply the orders

Input
TRGSJ XDOKI M VLN WPABE UQHCF ARRBBL0 ABCDE FGHIJ KLMNO PQRS TUVWX AAA LLLL0 ABCDE FGHIJ KLMNO PQRS TUVWX AAAAABBRRRLL0 Z

Output
Puzzle #1: T R G S J X O K L I M D V B N W P  A E U Q H C F

Puzzle #2: A B C D F G H I E K L M N J P Q R S O T U V W X

Puzzle #3: This puzzle has no final configuration.