add solution to problem 189 (but too slow)
add solution to problem 189