dam some algorithms