# DWITE Online Computer Programming Contest

## Working Directory

February 2009
Problem 3

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 the 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 set.

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

• ./ – current directory
• ../ – directory that’s a step above
• any_word/ – directory a step below

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:

• ./ – we’d stay where we are: /one/two/
• ././ – we’d continue to stay in /one/two/
• ../ – move one above: /one/
• ../../ – move two above: /
• ../../../ – move three above. One can’t move higher than root, so the result will stay at /
• ../three/./ – move up one, change directory to “three”, and stay there: /one/three/

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/```