# your code goes here def recursion_zenik(n,k,path=[]): if path and max(path)-min(path)>k: print('Zenik rule fail:',path) return 0 if n==0: print('Success:',path) return 1 return sum(recursion_zenik(n-i,k,path+[i]) for i in range(1,n+1)) print('Result =',recursion_zenik(5,2))
Standard input is empty
Success: [1, 1, 1, 1, 1] Success: [1, 1, 1, 2] Success: [1, 1, 2, 1] Success: [1, 1, 3] Success: [1, 2, 1, 1] Success: [1, 2, 2] Success: [1, 3, 1] Zenik rule fail: [1, 4] Success: [2, 1, 1, 1] Success: [2, 1, 2] Success: [2, 2, 1] Success: [2, 3] Success: [3, 1, 1] Success: [3, 2] Zenik rule fail: [4, 1] Success: [5] Result = 14