home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: sci.math.symbolic
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!sdd.hp.com!ux1.cso.uiuc.edu!news.cso.uiuc.edu!gaylord.slip.uiuc.edu!gaylord
- From: Richard J. Gaylord <gaylord@ux1.cso.uiuc.edu>
- Subject: "shut up and deal the cards"
- Message-ID: <Bzs70r.B1B@news.cso.uiuc.edu>
- X-Xxdate: Thu, 24 Dec 92 14:46:58 GMT
- Sender: usenet@news.cso.uiuc.edu (Net Noise owner)
- X-Useragent: Nuntius v1.1.1d13
- Organization: University of Illinois
- Date: Thu, 24 Dec 1992 20:46:01 GMT
- X-Xxmessage-Id: <A75F7DE25301164B@gaylord.slip.uiuc.edu>
- Lines: 22
-
- i figured out a way to deal a bridge hand that's more than three times
- faster than the version i posted a littel while ago..
-
- deck = Flatten[Outer[List,{c,d,h,s},Join[Range[2,10],{J,Q,K,A}]],1];
-
- SeedRandom[2]
- Timing[Partition[Transpose[Sort[Transpose[{Table[Random[],{52}],
- deck}]]][[2]],13];]
- {0.166667 Second, Null}
-
- SeedRandom[2]
- Timing[Partition[Map[#[[2]]&,
- Sort[Array[{Random[],#}&,52]]]/.Thread[Range[52]->deck],13];]
- {0.516667 Second, Null}
-
- =================
-
- the speed comes (i think) because i directly create the list
- {...{Random[], card}...} and use Transpose rather than a replacement rule
- (once again reaffirming the efficiency of functional programming.)
-
- good night to all and to all, a good night.
-