Services & Resources / Wolfram Forums / MathGroup Archive
-----

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: [mg91147] Re: Find count of binary number pattern within concatenated number
  • From: Albert Retey <awnl at gmx-topmail.de>
  • Date: Thu, 7 Aug 2008 04:41:33 -0400 (EDT)
  • References: <g7bqom$moc$1@smc.vnet.net>

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

I think you'd be better off to use the lists than transform to numbers.
Is this what you are after?

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

digitpattern = IntegerDigits[n, 2]

Count[Partition[digitlist, Length[digitpattern], 1], digitpattern]


hth,

albert


  • Prev by Date: User-Supplied Jacobian in NDSolve
  • Next by Date: RE: Find count of binary number pattern within concatenated number
  • Previous by thread: Re: Find count of binary number pattern within concatenated
  • Next by thread: Re: Find count of binary number pattern within concatenated number