DWITE Online Computer Programming Contest
February 2009
Problem 3
Working Directory

cd, sometimes also available as chdir (change directory), is a command line command to change the current working directory in operating systems such as Unix, DOS, OS/2 and Windows.

The input file DATA3.txt will contain 5 sets of input, 2 lines each. The first line of input will be a string representing the current location in the file system. The second will be a path to be taken, relative to the starting location. All strings (including output) will be non-empty and less than 255 characters.

The output file OUT3.txt will contain 5 lines, each corresponding to the new working directory of the input sets.

You may assume that all directories exist, and that paths given are valid. For those unfamiliar with traversing file structures on a computer, the key points are:

Example: if the working directory is /one/two/ it means that there is a root directory / which contains a directory one/ which, in turn, contains another directory two/. If we were to change directories as follows:

Sanity check: the first and last character of your output will always be a forward slash /

Sample Input:
/
one/two/
/
one/../two/
/
one/../../../two/
/
./one/
/one/two/
.././three/four/../
		        
Sample Output:
/one/two/
/two/
/two/
/one/
/one/three/