← Questions

Resolve a cd command to an absolute path

0
OpenAIMetaCodingLast asked Sep 2026

Write a function that takes the current directory and the argument to cd, and returns the directory pwd would print afterwards. Handle ., .., repeated and trailing slashes, and absolute targets. Later parts add shortcuts such as a home directory and symbolic links that remap one path prefix to another, including links that point at each other.

Write and test your solution herePython in your browser, the question's tests level by level, saved for you.Sign in to start coding