# I want the length 3 words on alphabet {0,1,2} with no two consecutive 1's [closed]

I tried this code but it doesn't work. DeleteCases[Tuples[{0, 1, 2}, 3], {_ 1, 1, _}].

## closed as off-topic by MarcoB, Bob Hanlon, xyz, dr.blochwave, C. E.Jun 12 '15 at 14:40

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." – MarcoB, Bob Hanlon, xyz, dr.blochwave, C. E.
If this question can be reworded to fit the rules in the help center, please edit the question.

• Try replacing _ with ___ (i.e. three underscores rather than one). Also, you have a missing comma. So: {___, 1, 1, ___}. – march Jun 11 '15 at 17:24
• Where the comma is missing? I think it multiples Blank (which is _) by 1, resulting in _. So you were trying to delete all cases that match {_, 1, _}, i.e. all triples with 1 in the center spot. By the way, the three underscores matches any sequence of 0, 1, or more elements. This makes it so that you can match, for instance, {1,1,0}. – march Jun 11 '15 at 17:29
• Errrr ... Not recommended Select[{{##} + 1, #1^#2 #2^#3} & @@@ (Tuples[{0, 1, 2}, 3] - 1) // Quiet, Last@# =!= Indeterminate &][[All, 1]] – Dr. belisarius Jun 11 '15 at 17:35
• Also not recommended, but using pattern matching Cases[{{##} + 1, #1^#2 #2^#3} & @@@ (Tuples[{0, 1, 2}, 3] - 1) // Quiet, {x_, y : Except[Indeterminate]} :> x] – Dr. belisarius Jun 11 '15 at 17:38
• @march A half-witted one ;) (({Abs[Times @@ (1 - Times @@ Partition[#, 2, 1])], #} & /@ Tuples[{0, 1, 2}, 3] // Sort // SplitBy[#, First] &) // Rest)[[All, All, 2]] // Flatten[#, 1] & – Dr. belisarius Jun 11 '15 at 18:14

DeleteCases[Tuples[{0, 1, 2}, 3], {1, 1, _} | {_, 1, 1}]

{{0, 0, 0}, {0, 0, 1}, {0, 0, 2}, {0, 1, 0}, {0, 1, 2}, {0, 2, 0},

This works because in this problem, for two ones to appear consecutively, they must be in the 1st two slots or (inclusively) the 2nd two slots. I think this should be a little faster than using ___, but it doesn't matter much with your very small alphabet.