some exercise in algorithm