Find all the permutations given some finite characters

In summary, the person is discussing difficulties they are having with programming, specifically the challenge of finding all permutations of a given set of n characters. They say that it is hard, but that they can do it "easily" on paper. However, when trying to do it in code they find it to be more difficult. They speculate that this may be because they need an algorithm to do the permuations in a specific order, without duplicates, and that programming is a way for the computer to follow these instructions. They also say that if they don't know how to program then this may be a barrier to doing the permutations. Finally, they say that if someone can't explain it to them then they presumably can
  • #1
jd12345
256
2
Well I am coming across problems like finding permutation of some n characters. On paper I can find all the permutations given some finite characters easily but when it comes to programming it is hard, why? Why is it hard to tell a computer what I myself can do it so easily?
This is strange - I mean I can do it myself so easily but I can't code it. Does this mean that I myself don't understand it?
 
Technology news on Phys.org
  • #2


The issue is that you need an algorithm to do the permuations in some specific order, without duplicates. A recursive method may be useful here. You could to a web search for "permuting an array", and find examples of code that does this, or you could grind it out. The two main operations are swapping and rotating of the characters.
 
  • #3


doing it without thinking is not quite enough, is it?

You need to do it once or twice and develop a set of steps, instructions that work every time and writ them down as if you were to give them to somebody else who does not how to do such thing and they should be able to follow your instructions and do it...

...then, you can give them to a computer...after all, computers are very stupid...they just do what you tell them to do!
 
  • #4


if i cannot explain it to someone then how am i able to do it ?
 
  • #5
jd12345 said:
Well I am coming across problems like finding permutation of some n characters. On paper I can find all the permutations given some finite characters easily but when it comes to programming it is hard, why? Why is it hard to tell a computer what I myself can do it so easily?
This is strange - I mean I can do it myself so easily but I can't code it. Does this mean that I myself don't understand it?
Maybe...

Are you sure you can do it yourself? For how long a string have you tried to find all the permutations of? How do you know you've successfully found all permutations?

How well do you know how to program? If you don't know how to program sufficiently well then obviously you won't necessarily be able to program what you know how to do...

Can you even describe in English how to enumerate over all permutations?
 

1. What is a permutation?

A permutation is a way of arranging a set of objects or characters in a specific order. It is a rearrangement of the elements of a set into a new sequence.

2. How do you find all the permutations given some finite characters?

To find all the permutations of a set of characters, you can use a mathematical formula or an algorithm. The formula for finding permutations is n!/(n-r)!, where n is the number of elements in the set and r is the number of elements to be selected for each permutation. Alternatively, you can use an algorithm such as the Heap's algorithm or the Johnson-Trotter algorithm to generate all possible permutations.

3. What is the difference between a permutation and a combination?

A permutation involves arranging a set of objects in a specific order, while a combination is a selection of objects from a set without considering the order. For example, the permutations of the letters A, B, and C are ABC, ACB, BAC, BCA, CAB, and CBA. The combinations of these letters would be ABC, AB, AC, BC, A, B, and C.

4. Can all sets of characters have permutations?

Yes, all sets of characters can have permutations. However, the number of permutations may vary depending on the length of the set. For example, a set of 3 characters can have 6 permutations, while a set of 4 characters can have 24 permutations.

5. In what fields is the concept of permutations used?

The concept of permutations is used in various fields such as mathematics, computer science, statistics, and cryptography. It is also commonly used in daily life for tasks such as creating unique passwords, shuffling a deck of cards, or arranging elements in a specific order.

Similar threads

  • Programming and Computer Science
Replies
9
Views
1K
  • Programming and Computer Science
Replies
4
Views
2K
  • Math Proof Training and Practice
Replies
23
Views
458
  • Programming and Computer Science
Replies
18
Views
2K
Replies
3
Views
806
  • Programming and Computer Science
Replies
7
Views
1K
  • Programming and Computer Science
Replies
4
Views
2K
  • Programming and Computer Science
Replies
1
Views
879
  • Programming and Computer Science
Replies
3
Views
845
  • Programming and Computer Science
Replies
7
Views
1K
Back
Top