Add docstring to problem 2 and 3 solutions

Addes a docstring and reformatted existing ones to match the common docstring
style guidelines. Also some minor renames of local variables/function arguments
which seemed a little bit odd now because of the thoughts made by writing a
docstring.