Re: Find count of binary number pattern within

• To: mathgroup at smc.vnet.net
• Subject: [mg91154] Re: [mg91093] Find count of binary number pattern within
• From: Bob Hanlon <hanlonr at cox.net>
• Date: Thu, 7 Aug 2008 04:42:53 -0400 (EDT)

```n = 13;

data1 = Flatten[IntegerDigits[Range[n], 2]]

{1,1,0,1,1,1,0,0,1,0,1,1,1,0,1,1,1,1,0,0,0,1,0,0,1,1,0,1,0,1,0,1,1,1,\
1,0,0,1,1,0,1}

Count[Partition[data1, 4, 1], {1, 1, 0, 1}]

4

data2 = FromDigits[Flatten[
IntegerDigits[Range[n], 2]]]

11011100101110111100010011010101111001101

Count[Partition[IntegerDigits[data2], 4, 1],
{1, 1, 0, 1}]

4

Length[StringCases[ToString[data2], "1101"]]

4

StringCount[ToString[data2], "1101"]

4

Bob Hanlon

---- Diana <diana.mecum at gmail.com> wrote:

=============
Math folks,

Can someone tell me how to find the count of the occurrences of "1101"
within "11011100101110111100010011010101111001101" generated with the
FromDigits statements below? I will be increasing "n".

n=13

FromDigits[Flatten[IntegerDigits[Range[n],2]]]

11011100101110111100010011010101111001101.

FromDigits[IntegerDigits[n, 2]]

1101

Diana

```

• Prev by Date: Re: Find count of binary number pattern within concatenated number
• Next by Date: Re: Re: Simplify
• Previous by thread: Re: Find count of binary number pattern within concatenated
• Next by thread: Mathematica and Mathieu DEQ Results?