# Recursive generation # on the example of generating k-tuples 1. Assignment: Generate a list of all k-digit numbers in the positional system with base n note: why not a for loop? # piece of mind: we have to generate k-tuples, e.g. k = 3, # this can be easily done using 3 nested for loops # what if k is a parameter and we don't know how many for cycles to create? # solving: recursion 1.2. Assignment: (small change of 1.) List all k-chars string from letters {"x","y","z"} note: different solution for each from list note: 2 solutions: a] digit extraction, b] foreach(char c in charArray) (2. Assignment: List all k-digit numbers in the positional system with base n, without repeating digits) 3. Assignment: List all k-digit increasing integer sequences in the interval <0, n-1> 4. Assignment: List all k non-decreasing digit sequences in the interval <0, n-1> 5. Assignment: List all k-length sequence consisting of the elements of the given set s elements from the set can be repeated in sequence e.g. set S = {"a", "b"} sequence k=3 can be ["a", "a", "b"] note: digit extraction 6. Assignment: List all k-length sequences consisting of the elements of the given set, each element of the set has a maximum number of repetitions specified The solution is to use a dict to store the elements of the set and the currently possible uses The solution is to use a 2D sheet to store the elements of the set and the currently possible uses 9. Assignment: List all k-element SETs consisting of the elements of the given multi-set, each element of the set has a maximum number of repetitions specified (ATM) 10.1. to find all the different decompositions of a given number N into the sum of positive integers note: the code generates the same tuples or their permutations, e.g. [4, 1] = 5 and [1, 4] = 5 solution: generate ascending sequences; not implemented (10.2 to find all such decompositions of a number N that have length K for a given number K) 12. Sudoku (solve, generate) - list of possible values for each cell - logic closure (All permutations of a given set) ??? You will find all non-short boxes that have the given sum "s" of positive integers of size up to "m" /////// Generate and test Too many falses