Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1995
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1995

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

Search the Archive

Re: Challenge!

  • To: mathgroup at christensen.cybernetics.net
  • Subject: [mg967] Re: [mg889] Challenge!
  • From: Jeffrey Merrill Dunn <dunnjm at mathlab1.Colorado.EDU>
  • Date: Thu, 4 May 1995 04:34:21 -0400

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!