update coding puzzle algorithm