MathGroup Archive 2008

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

Search the Archive

Re: Find count of binary number pattern within concatenated number

  • To: mathgroup at smc.vnet.net
  • Subject: [mg91140] Re: [mg91093] Find count of binary number pattern within concatenated number
  • From: "Thomas Dowling" <thomasgdowling at gmail.com>
  • Date: Thu, 7 Aug 2008 04:40:13 -0400 (EDT)
  • References: <200808060903.FAA22227@smc.vnet.net>

Hello,

If it is permissible to convert to a string, I suppose you could use:


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

In[25]= StringCount[ToString[exp], "1101"]

Out[25]= 4

In[26]= StringPosition[ToString[exp], "1101"]

Out[26]= {{1, 4}, {12, 15}, {25, 28}, {38, 41}}

Tom Dowling


On Wed, Aug 6, 2008 at 10:03 AM, 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
  • Next by Date: Re: Find count of binary number pattern within
  • Previous by thread: RE: Find count of binary number pattern within concatenated number
  • Next by thread: Re: Find count of binary number pattern within concatenated