Developed this during a code sprint on hackerrank.com (CodeSprint 5)