How should I make a selection from a list returned by Tuples?
Clash Royale CLAN TAG#URR8PPP
up vote
3
down vote
favorite
Select[Tuples[1, 1/2, 4, 4], Total [#] == 15]
I want to select all tuples in the result returned by Tuples
that have total of their elements equal to 15. The answer I got was only . Why?
list-manipulation tuples
New contributor
âðхõр Ñõý is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
up vote
3
down vote
favorite
Select[Tuples[1, 1/2, 4, 4], Total [#] == 15]
I want to select all tuples in the result returned by Tuples
that have total of their elements equal to 15. The answer I got was only . Why?
list-manipulation tuples
New contributor
âðхõр Ñõý is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
up vote
3
down vote
favorite
up vote
3
down vote
favorite
Select[Tuples[1, 1/2, 4, 4], Total [#] == 15]
I want to select all tuples in the result returned by Tuples
that have total of their elements equal to 15. The answer I got was only . Why?
list-manipulation tuples
New contributor
âðхõр Ñõý is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Select[Tuples[1, 1/2, 4, 4], Total [#] == 15]
I want to select all tuples in the result returned by Tuples
that have total of their elements equal to 15. The answer I got was only . Why?
list-manipulation tuples
list-manipulation tuples
New contributor
âðхõр Ñõý is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
âðхõр Ñõý is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited 1 hour ago


m_goldberg
82k869190
82k869190
New contributor
âðхõр Ñõý is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 1 hour ago
âðхõр Ñõý
183
183
New contributor
âðхõр Ñõý is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
âðхõр Ñõý is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
âðхõр Ñõý is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
4
down vote
accepted
tuples = Tuples[1, 1/2, 4, 4];
sel = Select[tuples, Total[#, 2] == 15 &];
Alternatively,
sel2 = Pick[tuples, Total[tuples, 3], 15];
sel == sel2
True
Grid @ Partition[GeneralUtilities`ColorArrayForm /@ sel, 12]
Grid[Partition[MatrixPlot[#, Frame -> False, ImageSize -> 40] & /@ sel, 12]]
add a comment |Â
up vote
0
down vote
There is an excelent answer with the illustration, but I would like to point out the specific mistakes:
- Pure function in the second argmuent should end with
&
Total[#]
by default only sums on the first level, but you need more.
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
accepted
tuples = Tuples[1, 1/2, 4, 4];
sel = Select[tuples, Total[#, 2] == 15 &];
Alternatively,
sel2 = Pick[tuples, Total[tuples, 3], 15];
sel == sel2
True
Grid @ Partition[GeneralUtilities`ColorArrayForm /@ sel, 12]
Grid[Partition[MatrixPlot[#, Frame -> False, ImageSize -> 40] & /@ sel, 12]]
add a comment |Â
up vote
4
down vote
accepted
tuples = Tuples[1, 1/2, 4, 4];
sel = Select[tuples, Total[#, 2] == 15 &];
Alternatively,
sel2 = Pick[tuples, Total[tuples, 3], 15];
sel == sel2
True
Grid @ Partition[GeneralUtilities`ColorArrayForm /@ sel, 12]
Grid[Partition[MatrixPlot[#, Frame -> False, ImageSize -> 40] & /@ sel, 12]]
add a comment |Â
up vote
4
down vote
accepted
up vote
4
down vote
accepted
tuples = Tuples[1, 1/2, 4, 4];
sel = Select[tuples, Total[#, 2] == 15 &];
Alternatively,
sel2 = Pick[tuples, Total[tuples, 3], 15];
sel == sel2
True
Grid @ Partition[GeneralUtilities`ColorArrayForm /@ sel, 12]
Grid[Partition[MatrixPlot[#, Frame -> False, ImageSize -> 40] & /@ sel, 12]]
tuples = Tuples[1, 1/2, 4, 4];
sel = Select[tuples, Total[#, 2] == 15 &];
Alternatively,
sel2 = Pick[tuples, Total[tuples, 3], 15];
sel == sel2
True
Grid @ Partition[GeneralUtilities`ColorArrayForm /@ sel, 12]
Grid[Partition[MatrixPlot[#, Frame -> False, ImageSize -> 40] & /@ sel, 12]]
edited 58 mins ago
answered 1 hour ago
kglr
161k8184384
161k8184384
add a comment |Â
add a comment |Â
up vote
0
down vote
There is an excelent answer with the illustration, but I would like to point out the specific mistakes:
- Pure function in the second argmuent should end with
&
Total[#]
by default only sums on the first level, but you need more.
add a comment |Â
up vote
0
down vote
There is an excelent answer with the illustration, but I would like to point out the specific mistakes:
- Pure function in the second argmuent should end with
&
Total[#]
by default only sums on the first level, but you need more.
add a comment |Â
up vote
0
down vote
up vote
0
down vote
There is an excelent answer with the illustration, but I would like to point out the specific mistakes:
- Pure function in the second argmuent should end with
&
Total[#]
by default only sums on the first level, but you need more.
There is an excelent answer with the illustration, but I would like to point out the specific mistakes:
- Pure function in the second argmuent should end with
&
Total[#]
by default only sums on the first level, but you need more.
answered 10 mins ago
Johu
3,1781033
3,1781033
add a comment |Â
add a comment |Â
âðхõр Ñõý is a new contributor. Be nice, and check out our Code of Conduct.
âðхõр Ñõý is a new contributor. Be nice, and check out our Code of Conduct.
âðхõр Ñõý is a new contributor. Be nice, and check out our Code of Conduct.
âðхõр Ñõý is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f182162%2fhow-should-i-make-a-selection-from-a-list-returned-by-tuples%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password