Solved problem 11

Made my brain hurt, loop edge condition hell.