fork(3) download
  1. f=lambda n,k:n>1<k and f(n,k-1)+f(n-1,k)or'987654321\n'[~n:]
  2.  
  3. for (n, k) in (5, 1), (5, 2), (5, 3), (3, 3), (2, 4), (2, 3), (1, 4):
  4. print (n, k)
  5. print f(n, k)
Success #stdin #stdout 0.01s 9024KB
stdin
Standard input is empty
stdout
(5, 1)
54321

(5, 2)
54321
4321
321
21
1

(5, 3)
54321
4321
321
21
1
4321
321
21
1
321
21
1
21
1
1

(3, 3)
321
21
1
21
1
1

(2, 4)
21
1
1
1

(2, 3)
21
1
1

(1, 4)
1