Message Boards Message Boards


New to Mathmatica and Programming in general (Need guidance)(combinatorics)

Posted 9 years ago
2 Replies
2 Total Likes

Permutations of [{4, 9, 2, 3, 6}]

For example I know there are 120 possibilities. However I can get them to display. I just do not know enough coding and language to sum all the possible permutations.

For example I want to add 49236 + 49263 + 49326........................... and so on.

I am trying to see if I do this for all 120 combinations I get a Palindrome

What should I do here?

POSTED BY: Dwight Ellender
2 Replies

Hi there,

the first two commands generate the list and the permutations, just like in Nasser's reply.

list = {4, 9, 2, 3, 6};
per = Permutations[list];

Then you need to combine the digits to Integers and add them up:

Total[FromDigits /@ per]

The result is 6399936 which indeed is palindromic.



POSTED BY: Marco Thiel

Where did you get 49236 + 49263 + 49326... from? since Total[{4, 9, 2, 3, 6}] is 24 and not 49236? Each permutation have the same total, just different arrangement. Either way, to sum them all, you can do

list = {4, 9, 2, 3, 6};
per = Permutations [list];

which gives 2880

I am trying to see if I do this for all 120 combinations I get a Palindrome

I am not sure I understand the above. But to find total of list of numbers, the command is Total.

POSTED BY: Nasser M. Abbasi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract