Click to reopen instructions.

Recursion over lists. Every method here takes a List<Integer> and is written the same way: a base case for the empty list (or the one-element list, where the empty list has no answer), and a recursive case that does something with the first element and the answer for the rest of the list. The starter code provides two helpers for taking a list apart: first(list) returns the first element and rest(list) returns a view of everything after it. Note that rest doesn’t copy the list, so calling it is cheap, but changing the view changes the original list. Neither helper can be called on an empty list.

No loops and no streams; the point is the recursion. Also no reaching for the library method that already does the job.

Put definitions here.

Revisions:

Test results show up here.

Errors