Let’s say I have a list of all the 3 digit numbers from 100 to 999 and I want to select those that have an {even, odd, even} parity digit pattern like 204, 678, etc. Is this possible using Select, or Cases or even Pick for I have tried all with no success? The nearest I came to some sort of selection was with this code.
and that didnt work either, which brings me back to the documentation where the syntax in your method isnt shown, i.e. the “/:” instead of “->”. So again I appreciate your input on this. and as you say the way you used it is easier to read.
I would translate the last line in english as something like.
Find those elements in mylist which are a list of length three.
Each time a list of three is found, temporarily name the first element a, the second element b, and the third element c.
Finally, accept those elements where a is even, b is odd, and c is even.
If you cut and paste this into the help browser (tutorial/PuttingConstraintsOnPatterns) you will see examples of the /; and _? usage.
Just for fun: the 900 numbers can be partitioned by the parity of the integer digits. Of the 8 (2x2x2) patterns the 4 which start with an odd number: they ae of size 125 (5 x5 x5) and the 4 starting with even number are of size 100 (4x5x5): 900=4 x125 +4x100.
You can partition into these equivalence classes:
num = GatherBy[Range[100, 999], EvenQ /@ IntegerDigits@# &];