Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #14676
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!newspump.sol.net!posts.news.twtelecom.net!nnrp3.twtelecom.net!not-for-mail |
|---|---|
| From | Felipe <fdimer@gmail.com> |
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: tossing a coin |
| Date | Thu, 30 May 2013 10:08:45 +0000 (UTC) |
| Sender | steve@smc.vnet.net |
| Approved | Steven M. Christensen <steve@smc.vnet.net>, Moderator |
| Message-ID | <ko78fd$dvb$1@smc.vnet.net> (permalink) |
| References | <20130526090801.381E86A52@smc.vnet.net> <ko1nbl$r31$1@smc.vnet.net> |
| Lines | 25 |
| Organization | Time-Warner Telecom |
| NNTP-Posting-Date | 30 May 2013 10:10:05 GMT |
| NNTP-Posting-Host | 6e84a19d.news.twtelecom.net |
| X-Trace | DXC=mQI\o79k1?D\dh8[i[NPkIC_A=>8kQj6MMOj3YM9`=aH=LiKeSdD3WMEFiONJ7[GoF4aVm3HK;O7O |
| X-Complaints-To | abuse@twtelecom.net |
| Xref | csiph.com comp.soft-sys.math.mathematica:14676 |
Show key headers only | View raw
Hi,
A variation of Dana's answer, if you'd like to keep the tossing results as a list
In[2]:= k = RandomChoice[{"h", "t"}, 30]
Out[2]= {"t", "h", "h", "h", "t", "t", "h", "t", "h", "h", "h", "t", \
"t", "t", "t", "h", "t", "h", "h", "t", "t", "t", "h", "h", "t", "h", \
"t", "t", "t", "h"}
In[8]:= k //. {x___, "t", "h", "h", y___} :> {x, "PATTERN A", y}
Out[8]= {"PATTERN A", "h", "t", "t", "h", "PATTERN A", "h", "t", "t", \
"t", "t", "h", "PATTERN A", "t", "t", "PATTERN A", "t", "h", "t", \
"t", "t", "h"}
A more literal way is to create the sequences by partitioning with padding
In[29]:= Position[Partition[k, 3, 1], {"t", "h", "h"}]
Out[29]= {{1}, {8}, {17}, {22}}
Best Regards
Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Find similar | Unroll thread
Re: tossing a coin michael partensky <partensky@gmail.com> - 2013-05-28 07:45 +0000 Re: tossing a coin Felipe <fdimer@gmail.com> - 2013-05-30 10:08 +0000
csiph-web