if a is [3,1,2], then the first element of b can only be 0, 1 or 2. The second element can only be 0. The third element can only be 0 or 1. All you need to do is to cycle through all the possibilities and build the lists.
Yes, I figured this out but I can't understand how to create a program using a recursive function which allows me to do it