We would like to generate all possible anagrams of a word. For example if the given word is 'TOP', there will be 6 possible anagrams:

```
TOP, TPO, OPT, OTP, PTO, POT
```

An anagram must be printed only once. You may output the anagrams in any order. Also output the total number of anagrams. You may assume that the number of letters, N, in the word will be 7 at most, i.e. N<=7

Test your program for the given data and some random data.

**SAMPLE DATA:**

```
INPUT: TO
OUTPUT: TO, OT
Total number of anagrams = 2
INPUT: LEAN
OUTPUT:LEAN, LENA, LAEN, LANE, LNEA, LNAE, EALN, EANL,
ELAN, ELNA, ENLA, ENAL, ALNE, ALEN, ANLE, ANEL,
AENL, AELN, NLEA, NLAE, NELA, NEAL, NALE, NAEL.
Total number of anagrams=24
```

### Have something to say? Log in to comment on this post.

0 comments