Results for query "Find a recurrence relation for the number of ternary strings of length ݊ that do not contain two consecutive 0s and two consecutive 1s. "

Algorithm for 'good' number

A give number x is 'good' if the sum of any two consecutive digit of the number x are between k and 2k.I need to find an algorithm that for a given number k and a given number n, find how many 'good' n-digit numbers exist.

Sum of two consecutive squares equals difference of two consecutive cubes

My upcoming 61st birthday was challenging, but then
I noticed that $61 = 5^2 + 6^2 = 5^3 - 4^3$, the sum of two consecutive squares
and the difference of two consecutive cubes.I wondered what other numbers
had this property; that is, the integer solutions to
$a^2+(a+1)^{2} = (b+1)^3 - b^3$ or equivalently $2a^2+2a = 3b^2+3b$.

Probability of at most $K$ consecutive zeroes in a sequence of 0s and 1s [closed]

I want to prove that in a sequence W of length n, consisting of 1s and 0s, $P$( in $W$ there is at most $\frac{\log_2n}2$ consecutive zeroes ) $\leq \frac{K}{n} $ for some constant K.I prove that for large $n$:

1) the probability that a random sequence of length $n$ has at least $B:=b\log_2 n$ consecutive zeroes is at most $n^{1-b}$;

2) the probability that a random sequence of length $n$ does not contain $A:=\lfloor a\log_2 n\rfloor$ consecutive zeroes is at most $e^{-n^{1-a+o(1)}}=O(n^{-M})$ for any $M>0$.

Will a given pattern ever show up in an infinite random sequence of 0s and 1s?

Here the pattern is a finite or infinite sequence of 0s and 1s, not necessarily consecutive, for example, $\lbrace 1, *, 1, *, 1 \rbrace$ and $\lbrace 0, *, 0, *, 0, *, \ldots \rbrace$ ($ * $, hole position not cared), which is to be moved along a given infinite binary sequence for a match.If the pattern is finite, the probability of that pattern ever showing up in a randomly selected infinite binary sequence is $1$ (random in the sense of flipping a fair coin).

R: Sum values that are in different parts of vector

I have a number of vectors consisting of 1s and 0s, such as:

[1] x <- c(0, 1, 1, 0, 0, 1)

I would like to count the number of consecutive 1s at different parts of these sequences, and in this instance end up with:

[1] 2 1

I have considered using something like strsplit to split the sequence where there are zeros, though it is a numeric vector so strsplit won't work and ideally I don't want to change back and forth between numeric and character format.Is there another, simpler, solution to this?