Problem 4, Python
Those evil whitespaces...
What a error in reasoning...

New solution is less "clever", but more correct
Problem 5, Python