New answers tagged searching
7
But I would like to know the positions of "Element 1" and "Element 2"...
You can still use Position[]; things are a little more elaborate, though, due to the strings:
Position[list, s_String /; StringMatchQ[s, "El*"]]
{{4}, {7}}
Extract[list, %]
{"Element 1", "Element 2"}
3
A possibility:
Cases[list, x_String /; StringMatchQ[x, "El*"]]
{"Element 1", "Element 2"}
5
Select[list, StringMatchQ[ToString@#, "El" ~~ ___] &]
{"Element 1", "Element 2"}
3
String matching works a little better. Think of each row in the board as a string on the alphabet {"0", "1"}. The "pattern" is a set of instructions to look for particular configurations of "0" on the board, because a presence of a "1" in the pattern is no restriction at all and a "0" in the pattern means there must be a corresponding "0" on the board. ...
5
It seems I misunderstood the question. Here's an update, which is a considerable improvement, too. It relies on Implies[x, y] being equivalent to Boole[x] (1 - Boole[y]) == 0.
falsePattern = Table[False, {15}, {15}];
truePattern = Table[True, {15}, {15}];
SeedRandom[1];
randomPattern = RandomChoice[{True, False}, {15, 15}];
impliesPosition[board_, ...
Top 50 recent answers are included
