Re: tossing a coin

• To: mathgroup at smc.vnet.net
• Subject: [mg130968] Re: tossing a coin
• From: Felipe <fdimer at gmail.com>
• Date: Thu, 30 May 2013 06:15:05 -0400 (EDT)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com
• Delivered-to: l-mathgroup@wolfram.com
• Delivered-to: mathgroup-outx@smc.vnet.net
• Delivered-to: mathgroup-newsendx@smc.vnet.net
• References: <20130526090801.381E86A52@smc.vnet.net> <ko1nbl\$r31\$1@smc.vnet.net>

```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

```

• References:
• Prev by Date: Re: Warsaw Univ. course, was Re: Work on Basic Mathematica Stephen!
• Next by Date: Applying Mathematica to practical problems
• Previous by thread: Re: tossing a coin
• Next by thread: Re: tossing a coin