0
$\begingroup$

How can I create all possible lists of twelve elements when each element can be -1 or 1. That is, 2^12 different lists.

$\endgroup$

closed as off-topic by Henrik Schumacher, Alex Trounev, bbgodfrey, m_goldberg, Bob Hanlon Apr 28 at 19:33

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Henrik Schumacher, Alex Trounev, bbgodfrey, m_goldberg, Bob Hanlon
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    $\begingroup$ You are looking for all 12-tuples of $\{-1, 1\}$. Tuples is of course the the keyword to look up in the documentation. $\endgroup$ – Henrik Schumacher Apr 28 at 8:32
3
$\begingroup$

You can use Tuples:

res = Tuples[{-1,1}, 12];
% //Length
res[[;;10]]

4096

{{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {-1, -1, -1, -1, -1, -1, \ -1, -1, -1, -1, -1, 1}, {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1}, {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1}, {-1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1}, {-1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1}, {-1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1}, {-1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1}, {-1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1}, {-1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1}}

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.