UVa 630

From Algorithmist
Jump to: navigation, search

630 - Anagrams (II)[edit]

Summary[edit]

Given a dictionary of words. Then given a set of words find all its permutation in the dictionary.

Explanation[edit]

  • This all comes down to sorting. A permutation will be exactly the same when it is sorted.
  • Keep a list of sorted and unsorted words.

Input[edit]

1

8
atol
lato
microphotographics
rata
rola
tara
tola
pies
tola
kola
aatr
photomicrographics
END

Output[edit]

Anagrams for: tola
  1) atol
  2) lato
  3) tola
Anagrams for: kola
No anagrams for: kola
Anagrams for: aatr
  1) rata
  2) tara
Anagrams for: photomicrographics
  1) microphotographics

References[edit]