DWITE '09 R1 #2 - Word Scrambler

View as PDF

Submit solution

Points: 5
Time limit: 2.0s
Memory limit: 64M

Problem type
DWITE Online Computer Programming Contest, October 2009, Problem 2

Looking to find some clever anagrams, you want a helper tool that will list all possible arrangements of letters for a given source word. To make the list easier to scan, the output should be in ascending sorted order.

The input contains 5 lines, string of lower-case alphabet characters, at least 1 character long, and no more than 5.

The output contains all the possible combinations of letters in each word, sorted alphabetically.

To make things easier, all of the letters in each word are guaranteed to be unique (so then every combination will also be unique).

Note: since there are n! possibilities for combinations of n letters, you can use that fact to check that you have the right number of possibilities in your output.

Sample Input

a
ab
abc

Sample Output

a
ab
ba
abc
acb
bac
bca
cab
cba

Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0) Problem Resource: DWITE


Comments


  • 6
    CheezWhiz  commented on Feb. 10, 2019, 12:59 p.m.

    Sample input should be five lines