Your question is Normalize a URI Path. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Given a URI, normalize it (for example, /a/../b/c -> /b/c).
Treat the input as an absolute URI path containing slash-separated segments. Resolve . and .., collapse repeated slashes, and prevent .. from moving above the root. Preserve a trailing slash when the normalized result is not /.
Implement normalize_uri(uri), which accepts a string and returns the normalized path string. Inputs contain no query string or fragment.
/def normalize_uri(uri):