Group Abstract Group Abstract

Message Boards Message Boards

0
|
3.1K Views
|
1 Reply
|
0 Total Likes
View groups...
Share
Share this post:

Permutations with deleting rows inside a table?

Posted 7 years ago

Hello.

f[sum_, quant_] := 
 Flatten[Permutations /@ 
   IntegerPartitions[sum, {quant}, Range[0, sum]], 1]
t = {10, 20};
Table[Join[Table[{n - j}, {i, j + 1}], 
  Table[{t[[1]], t[[2]]}, {i, j + 1}]*
   f[j, 2], {Total[Table[{t[[1]], t[[2]]}, {i, j + 1}]*f[j, 2], {2}]},
   2], {j, 2, 2}]

I want to generate the matrix of all possoble outcomes. The problem is I cannot add forth column with the sum of rows of second and third columns. I guess this is because my total go with {20,30,40} at the time I need {{20},{30},{40}} After all I want to delete all columns inside a table which do not satisfy the candition using something like that

Select[Table..., #[[4]] <= t[[1]](3-j) + t[[2]]-n-j &] 

Regards,

Alex

POSTED BY: Alex Graham
Anonymous User
Anonymous User
Posted 7 years ago

your loop is getting illegible. if you read the Mathematica Book (i like version 4.0 book, arranged as book), you see you have options to avoid tangling yourself into a nested table

Map[List, {{20,30,40}}] == {{20},{30},{40}}

Partition[Flatten[list1],1,1] == same

i suggest you completely re-organize your work so you are working in with one operation at a time on a table. such as "create colum" , "add column 2,3", ... mathematica is effortless to use when using "list programming". but read what that is all about from the book.

POSTED BY: Anonymous User
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard