Make some changes to the first problem.

Add docstring and put the constant outside the function.
Improve second problem.
Fix stupidity in the first solution.
Make minor changes in the third solution.