Common Lines
Created on April 10, 2025 by Julien Palard
Write a program that searches for common lines between multiple given files.
Your program accepts file names as parameters in sys.argv).
Example:
1 2 |
|
If no file are given, your program must print some help, then exit with a return code greater than zero.
If no lines are common between the given files, your program must exit with an error code greater than zero.
The line order can be ignored: if a file a
contains:
1 2 |
|
and a file b
contains:
1 2 |
|
then they have two common lines, and you program can either print:
1 2 |
|
or:
1 2 |
|
both are valid.
If more than two files are given, your program must print lines common to all files, example :
If the file a
contains:
1 2 3 |
|
The file b
:
1 2 |
|
And the file c
:
1 2 |
|
Then python common-lines.py a b c
should only print Hello
.
Empty lines must be ignored.
File will always be encoded using UTF-8
.
If any given name points to an existing file, or to a file that cannot be decoded using UTF-8, your program must print an error message an exit with a return code greater than zero.