Level 2 · Core
Free Recursion lessons
8 lessons, about 84 minutes in all. Each teaches one idea with a visual, then gives you one problem built for it. Read the lessons here, then create a free account to solve the problems and keep your progress.
Stage 0A function that calls itself
- Sum of digitsAnswer a tiny case directly, and hand everything else to a smaller call.8 min
- Reverse a stringDo your part after the smaller call returns, and the answer builds on the way back.9 min
- Same both waysWalk a list by passing positions down the calls, not by copying it.10 min
- Power in a few stepsHalve the problem instead of shrinking it by one, and a huge input needs only a few calls.12 min
Stage 1Lists and strings
- The first value and the restAdd up a list by taking the first value and trusting a smaller call to add up the rest.10 min
- Split the list in twoFind the biggest value by finding the biggest of each half and keeping the larger.11 min
- Cancel neighbouring twinsBuild the answer for a string from the answer for its shorter tail, fixing up the front on the way back.13 min
- Write a number in binaryTurn a number into its binary text by writing the answer for half the number, then the last bit.11 min
There’s more after this
These are the opening stages of Recursion. The full path climbs on to harder problems and a mastery test. Create a free account and we’ll keep your place.
Start the full path free