Added my attempt at iterative solution and patrick's solution