Add solution to #39
Add solution to #107