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?


There was an excelent answer with an 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.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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