This was pretty straightforward. The first thing that I wanted to do is to point my input stream at the file we’re given. So just the following line.
The next thing we want is to read the chunk of names all at once so
The chunk saved in str will look this
Now we want to split them based on the delimiter “,” and we also want to take out the first and last character
Next, we want to sort the list of names. We can just use std::sort. I’m assuming years ago, this was painful to do.
Finally, we want to calculate the score as follows. (Remember that “A-A=0”, so we can just subtract “A” to get the score we want for each letter in the name).