MathGroup Archive 1995

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

Search the Archive

Re: Challenge!


I don't know if this is the best coding but this is what I came up with :

 	Swap[list1_,list2_] :=
	Map[Apply[Plus,{{0,1},{1,0}}[[Random[Integer,{1,2}]]] #]&,
			Transpose[{list1,list2}]]

In[37]:=
Swap[{a1,b1,c1,d1,e1,f1,g1},{a2,b2,c2,d2,e2,f2,g2}]
Out[37]=
{a2, b1, c2, d2, e2, f1, g1}
In[38]:=
Swap[{a1,b1,c1,d1,e1,f1,g1},{a2,b2,c2,d2,e2,f2,g2}]
Out[38]=
{a1, b1, c2, d1, e1, f1, g1}
In[39]:=
Swap[{a1,b1,c1,d1,e1,f1,g1},{a2,b2,c2,d2,e2,f2,g2}]
Out[39]=
{a2, b2, c1, d2, e1, f2, g1}
In[40]:=
Swap[{a1,b1,c1,d1,e1,f1,g1},{a2,b2,c2,d2,e2,f2,g2}]
Out[40]=
{a2, b2, c1, d2, e2, f2, g1}
In[41]:=
Swap[{a1,b1,c1,d1,e1,f1,g1},{a2,b2,c2,d2,e2,f2,g2}]
Out[41]=
{a1, b1, c2, d2, e1, f2, g1}
In[42]:=
Swap[{a1,b1,c1,d1,e1,f1,g1},{a2,b2,c2,d2,e2,f2,g2}]
Out[42]=
{a2, b1, c1, d1, e1, f1, g2}


  • Prev by Date: Re: What's this Mathematica function called?
  • Next by Date: Saving postscript files
  • Previous by thread: Re: Challenge!
  • Next by thread: Re: Challenge!