← Back to problems
UNSW COMP2041 · medium

21T2 Q6 — Mirrored files

Two files are mirrored if they contain the same lines in the reverse order. Given two filenames as arguments, print exactly one line:

  • different line counts → Not mirrored: different number of lines: A versus B
  • else first differing position → Not mirrored: line K different (line number in the first file)
  • otherwise → Mirrored

Python only; no external programs / subprocess. From COMP2041/9044 21T2 Final.