I want to generate triplets of random integers over where the integers are in the range -9 to 9 (inclusive) but excluding zero. How can I do that?
I have the following table.
Table[a -> RandomInteger[{-9, 9}, 3], {50}] // Column
{a -> {0, 9, 6}}, {a -> {7, -3, 1}}, {a -> {-8, -2, -6}}, {a -> {9, 0, 2}}, {a -> {-2, 5, 6}}, {a -> {0, 4, -2}}, {a -> {8, -5, -1}}, {a -> {3, -4, -9}}, {a -> {-8, 7, 6}}, {a -> {-9, 8, 5}}, {a -> {2, -1, 9}}, {a -> {7, 0, 2}}, {a -> {5, -2, 0}}, {a -> {1, -9, -6}}, {a -> {0, -8, 0}}, {a -> {-9, -9, -2}}, {a -> {9, -2, -3}}, {a -> {6, -1, -5}}, {a -> {-3, 2, 1}}, {a -> {-7, 3, 0}}, {a -> {8, 4, -5}}, {a -> {-9, -1, 0}}, {a -> {1, 0, -4}}, {a -> {0, -4, 3}}, {a -> {-1, -9, -6}}, {a -> {9, 8, -3}}, {a -> {6, -2, 4}}, {a -> {2, 3, 8}}, {a -> {-9, 1, -4}}, {a -> {8, -1, -9}}, {a -> {-7, 7, 9}}, {a -> {-8, -7, 2}}, {a -> {2, 3, -7}}, {a -> {-2, 9, 5}}, {a -> {9, 1, 0}}, {a -> {8, 0, -6}}, {a -> {-4, -8, 1}}, {a -> {8, -5, 6}}, {a -> {-9, -4, -9}}, {a -> {9, 7, -8}}, {a -> {9, 8, -5}}, {a -> {9, 5, 5}}, {a -> {-4, -5, -4}}, {a -> {-3, 2, 0}}, {a -> {-9, -9, 0}}, {a -> {-7, 1, -4}}, {a -> {7, 6, -5}}, {a -> {-4, 1, -6}}, {a -> {-5, -9, 0}}, {a -> {-6, 2, -6}}
I don't want the zeros that appear above. I have used DeleteCasesand Replace
with no results,
Table[a -> Table[(-1)^RandomInteger[{1, 2}] RandomInteger[{1, 9}], {3}], {50}] // Column
$\endgroup$DeleteCases
andReplace
$\endgroup$