algorithm homework code