UVa 630

From Algorithmist

Jump to: navigation, search

Contents

[edit] 630 - Anagrams (II)

[edit] Summary

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

[edit] Explanation

  • 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.

[edit] Input

1

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

[edit] Output

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

[edit] References

Personal tools