(Slow) #12 solution