BRIAN YU: Let's start by taking a look at lines.
In this part of the problem, here's what you'll have to do.
First, the lines function is a function defined
in helpers.pi which takes in inputs a and b, each of which are strings.
The first thing you'll have to do is take each of those strings
and split them up into individual lines.
Then you'll need to figure out which lines appear both in a and in b.
And then finally, you'll want to return a list that
contains all of the lines that are present in both string
a and also string b.
So let's take a look at what that would actually look like.
A string might look something like this, line one backslash n, line 2 backslash
n, line 3 where the backslash n stands for new lines.
If we want to take a string like this and split it up
into lines, what that means is that we want
to convert this string into separate lines, line one, line two, and line
three.
That way we can compare between file a and file
b, which lines are present in both of those files.
Know that Python strings do support methods, which
may help you in the process of trying to take a string
and extract out all of the lines that appear in that string.
And you can go to this URL, part of Python's documentation,
to look at the methods that you can use with Python strings.
And some of them may help you to figure out how to take a string
and split it up into its individual lines.
After you've taken both a and b and split them up into their lines,
the next step is going to be to figure out
which lines appear in both the lines of a and also the lines of b.
So how do we find the lines that are going to be in common?
Well, you'll probably want to consider some sort of data structure
to keep track of which lines are present in both.
You might consider a list which just stores elements in order
Or you might want to consider a set which stores elements not in order
and just stores a collection of them.
Or you might want to consider some other data structure altogether.
It's up to you.
But you might want to take a look at this part of Python's documentation
which explains some of the common Python data structures that
might prove helpful to you as you think about what algorithm to use
and what data structure to consider, as you
think about how to find which lines are present in both a and b.
Key things to make sure of are that you are avoiding duplicate lines.
If, for example, the same line appears twice in file a and three times in file
b, you only want that to appear one time in your resulting list.
Because the list that you return at the end of the lines
function should be a list of all of the lines
that the two files have in common.
But each one of those lines in common should only appear once at maximum.
So be sure to avoid duplicates there and think
about how you might make sure your algorithm is
careful to avoid that situation.