LearnPy Hub
← Recursion & Lambda problems
Hard

Choose k Items

Write a recursive function that prints every way to choose k items from the words (keeping their order), one choice per line, in the order the recursion finds them (include the first word before skipping it).

Input

Words on one line, then k.

Output

Lines.

Sample 1

Input
a b c d
2
Output
a b
a c
a d
b c
b d
c d

Sample 2

Input
x y
1
Output
x
y
solution.py
Output appears here
Choose k Items · Python practice problem · LearnPy Hub