Add #52 solutions for Python and Ruby