some basic algorithm  exercise code.