# Should I use design patterns or an algorithm? And what's the difference?

I have been given a task of finding the permutations of the letters of a given word. For example, if the given word is like then possible answers are liek, lkie, and so on. This can be implemented in any language, but the rule is not to use any built-in functions/API to find the combinations.

We know that design patterns are for solving any problem with a given solution. For example, Information Expert is a design pattern. Is there any design pattern for finding combinations? Or will design patterns not suit for this situation? Will I have to learn a good algorithm for finding the solution? In that case, what’s the difference between an algorithm and a design pattern? Both try to solve the problem in a good, efficient way, right?

Please correct me if I’m wrong!

-
Are you just making random changes to the string? Finding all the possible combinations of the letters? The problem is not very well specified, IMO... – Dean Harding Mar 20 '11 at 11:11
I'm just swapping the first two letters and check in the answer list(which hold answers) for duplicates, if they found already then i will skip,then i will swap the next second and third letter and keep on goes untill i found the answer. The loop will get exit if it done all the combinations, that is before entering the loop i will found the number of possible of combinations which then act as upper bound for my loop! – Ant's Mar 20 '11 at 11:20
That sounds.... expensive! – Kenneth Mar 20 '11 at 15:28
The number of combinations is n! for a n letter word assuming all letters are unique. Handling duplicate letters could be a major pain with this kind of problem but this does seem like a common Combinatorics problem to my mind. – JB King Mar 24 '11 at 22:13
You say you're looking for combinations, but your example is of finding permutations. Also, the number of combinations for a string of length n containing no duplicate letters is not n!; the number of permutations is. – user16764 Apr 21 '11 at 16:22