If you want to stick to Outer
try Outer[List,numbers,numbers]
.
Finding all possible outcomes of two dice using Outer in Mathematica
-
03-10-2022 - |
Question
I am just getting started with Wolfram Mathematica 9, and am trying to learn how to use the Outer function. I have a problem where I want to generate a list containing all possible outcomes from rolling two dice. I have the following list to start with.
numbers = { 1, 2, 3, 4, 5, 6 }
The list I want to generate should be on the following form.
{ { 1, 1 }, { 1, 2 }, { 1, 3 }, ..., { 6, 6 } }
I have tried things like
Outer[Times, numbers, numbers]
to no avail. How do I solve this problem?
Thank you in advance!
Solution
OTHER TIPS
As alluded to, there is another way to do this. Consider Subsets[Range[1, 6], {2}]
You can also use Join
by Outer[{#1}~Join~{#2},numbers,numbers]
.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow