MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Set construction with condition

  • To: mathgroup at smc.vnet.net
  • Subject: [mg61527] Re: Set construction with condition
  • From: "dkr" <dkrjeg at adelphia.net>
  • Date: Fri, 21 Oct 2005 00:38:12 -0400 (EDT)
  • References: <dj71qk$cmn$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Edson,

In[87]:=
f[i_,j_,k_,m_]:=Sequence[]/;MatchQ[Sort@{i,j,k,m},{1,1,1,_}];
f[i_,j_,k_,m_]:=StringJoin[{"1","X","2"}[[{i,j,k,m}]]];

In[89]:=
f@@@Flatten[Table[{i,j,k,m},{i,3},{j,3},{k,3},{m,3}],3]
Out[89]=
{11XX,11X2,112X,1122,1X1X,1X12,1XX1,1XXX,1XX2,1X21,1X2X,1X22,121X,1212,12X1,\
12XX,12X2,1221,122X,1222,X11X,X112,X1X1,X1XX,X1X2,X121,X12X,X122,XX11,XX1X,\
XX12,XXX1,XXXX,XXX2,XX21,XX2X,XX22,X211,X21X,X212,X2X1,X2XX,X2X2,X221,X22X,\
X222,211X,2112,21X1,21XX,21X2,2121,212X,2122,2X11,2X1X,2X12,2XX1,2XXX,2XX2,\
2X21,2X2X,2X22,2211,221X,2212,22X1,22XX,22X2,2221,222X,2222}
In[90]:=
L=Flatten[

Outer[StringJoin,{"1","X","2"},{"1","X","2"},{"1","X","2"},{"1","X",
          "2"}]];
In[91]:=
Select[L,StringCount[#,"1"]<3&]
Out[91]=
{11XX,11X2,112X,1122,1X1X,1X12,1XX1,1XXX,1XX2,1X21,1X2X,1X22,121X,1212,12X1,\
12XX,12X2,1221,122X,1222,X11X,X112,X1X1,X1XX,X1X2,X121,X12X,X122,XX11,XX1X,\
XX12,XXX1,XXXX,XXX2,XX21,XX2X,XX22,X211,X21X,X212,X2X1,X2XX,X2X2,X221,X22X,\
X222,211X,2112,21X1,21XX,21X2,2121,212X,2122,2X11,2X1X,2X12,2XX1,2XXX,2XX2,\
2X21,2X2X,2X22,2211,221X,2212,22X1,22XX,22X2,2221,222X,2222}
In[92]:=
Union[%89]===Union[%91]
Out[92]=
True

Strictly speaking, the first method above satisfies your criteria,
since the bad strings are never calculated.  But both methods do
involve "filtering" an 81 element list.


  • Prev by Date: Re: Re: Re: DSolve and matrix form of system of equations
  • Next by Date: Re: Window names in Mathematica under Linux/KDE
  • Previous by thread: Re: Set construction with condition
  • Next by thread: Re: Set construction with condition