exercise for algorithms