← Questions

Simplified filesystem with paths and traversal

0
AnthropicCodingLast asked May 2026

Implement a small filesystem with path lookup and directory traversal, extended in the final level with model-related behavior. The harness is strict, so edge cases around paths matter.

  • Level 1: mkdir(path) (creates parents), write(path, content), read(path), ls(path).
  • Level 2: rm(path) (recursive, never /), mv(src, dst).
  • Level 3: find(path, suffix="") and du(path).
  • Level 4: checkpoints named step-<n>.ckpt: latest_checkpoint(dir) and prune_checkpoints(dir, keep).
class FileSystem:
    def mkdir(self, path): ...
    def write(self, path, content): ...
    def read(self, path): ...
    def ls(self, path): ...

    def rm(self, path): ...
    def mv(self, src, dst): ...

    def find(self, path, suffix=""): ...
    def du(self, path): ...

    def latest_checkpoint(self, path): ...
    def prune_checkpoints(self, path, keep): ...
Write and test your solution herePython in your browser, the question's tests level by level, saved for you.Sign in to start coding