week 5 algorithm