Right solution to exercise 5.4, this solution generates all possible combinations of a array