LearnPy Hub
← Recursion & Lambda problems
Hard

All Arrangements

Read a word with distinct letters and print every arrangement of its letters in alphabetical order, one per line, using recursion.

Input

One word (up to 5 distinct letters).

Output

One line per arrangement.

Sample 1

Input
abc
Output
abc
acb
bac
bca
cab
cba

Sample 2

Input
a
Output
a
solution.py
Output appears here
All Arrangements · Python practice problem · LearnPy Hub