Some exercise code during my reading through this classical algorithm book. I will try to write in Swift