Hi brkyrhrt99_00:
I cleaned the file up a bit and added some comments for you. The Maple
input and comments are as follows. (Input lines have a > in front of
them, comments do not.)
> with(combinat);
Find all the compositions of 20 of 4 or less non-negative integers.
> allcomps := [op(composition(20,1)), op(composition(20,2)),
op(composition(20,3)), op(composition(20,4))];
Convert all the compositions to lists of 4 integers by padding with
zeroes.
> allcomps2 := [];
> for i from 1 to nops(allcomps) do
> if nops(allcomps[i]) < 4 then
> allcomps2 :=
[op(allcomps2),[0$(4-nops(allcomps[i])),op(allcomps[i])]]:
> else
> allcomps2 := [op(allcomps2),allcomps[i]]:
> fi;
> od:
> allcomps2;
Sort inside the individual compositions.
> allcomps3 := map(sort, allcomps2):
> allcomps3;
Remove duplicate entries.
> alluncomps := [];
> for i from 1 to nops(allcomps3) do
> if member(allcomps3[i], alluncomps) then
> next;
> else
> alluncomps := [op(alluncomps), allcomps3[i]]:
> fi:
> od:
> alluncomps;
How many are there?
> nops(alluncomps);
Find the number of possible permutations for each composition.
> map(numbperm, alluncomps, 4);
Sum the values up.
> convert(%, `+`);
I removed the output because it was really long.
Hope this helps!
websearcher-ga |
Clarification of Answer by
websearcher-ga
on
22 Sep 2002 10:09 PDT
Actually, it is for computing *both* when ordering does and when it
doesn't count. In my method, you must compute without ordering first
in order to then compute with ordering. One follows from the other.
I've added a few additional comments to help you understand better.
> with(combinat);
Find all the compositions of 20 of 4 or less non-negative integers.
> allcomps := [op(composition(20,1)), op(composition(20,2)),
> op(composition(20,3)), op(composition(20,4))];
Convert all the compositions to lists of 4 integers by padding with
zeroes.
> allcomps2 := [];
> for i from 1 to nops(allcomps) do
> if nops(allcomps[i]) < 4 then
> allcomps2 := [op(allcomps2),
> [0$(4-nops(allcomps[i])),
> op(allcomps[i])]]:
> else
> allcomps2 := [op(allcomps2),allcomps[i]]:
> fi;
> od:
> allcomps2;
Sort inside the individual compositions so that we can later eliminate
duplicate entries.
> allcomps3 := map(sort, allcomps2):
> allcomps3;
Remove duplicate entries to find the number of compositions when
ordering does not count.
> alluncomps := [];
> for i from 1 to nops(allcomps3) do
> if member(allcomps3[i], alluncomps) then
> next;
> else
> alluncomps := [op(alluncomps), allcomps3[i]]:
> fi:
> od:
> alluncomps;
How many are there?
> nops(alluncomps);
Find the number of possible permutations for each individual
composition in order to compute how many compositions there are when
ordering does count.
> map(numbperm, alluncomps, 4);
Sum the values up.
> convert(%, `+`);
I have also put a copy of the complete document (output included)
online if you want to view it.
http://www.lucidmatrix.com/uploads/20output.txt
websearcher-ga
|