Submitted solution

Used the sprint function to format and remove the loops