Suppose I have n bits, all initially 0. I can flip any m of the bits (does not have to be contiguous) at a time (one operation). How many operations is required? When is it not possible? It seems that the answer is always in [n/m, n/m + 2] when it's possible to do so.
2026-04-03 11:11:27.1775214687
N bits, flip exactly M bits at a time, what is minimum number of operations to get all 0's to all 1's?
575 Views Asked by Bumbble Comm https://math.techqa.club/user/bumbble-comm/detail At
1
There are 1 best solutions below
Related Questions in LINEAR-ALGEBRA
- An underdetermined system derived for rotated coordinate system
- How to prove the following equality with matrix norm?
- Alternate basis for a subspace of $\mathcal P_3(\mathbb R)$?
- Why the derivative of $T(\gamma(s))$ is $T$ if this composition is not a linear transformation?
- Why is necessary ask $F$ to be infinite in order to obtain: $ f(v)=0$ for all $ f\in V^* \implies v=0 $
- I don't understand this $\left(\left[T\right]^B_C\right)^{-1}=\left[T^{-1}\right]^C_B$
- Summation in subsets
- $C=AB-BA$. If $CA=AC$, then $C$ is not invertible.
- Basis of span in $R^4$
- Prove if A is regular skew symmetric, I+A is regular (with obstacles)
Related Questions in NUMBER-THEORY
- Maximum number of guaranteed coins to get in a "30 coins in 3 boxes" puzzle
- Interesting number theoretical game
- Show that $(x,y,z)$ is a primitive Pythagorean triple then either $x$ or $y$ is divisible by $3$.
- About polynomial value being perfect power.
- Name of Theorem for Coloring of $\{1, \dots, n\}$
- Reciprocal-totient function, in term of the totient function?
- What is the smallest integer $N>2$, such that $x^5+y^5 = N$ has a rational solution?
- Integer from base 10 to base 2
- How do I show that any natural number of this expression is a natural linear combination?
- Counting the number of solutions of the congruence $x^k\equiv h$ (mod q)
Related Questions in ELEMENTARY-NUMBER-THEORY
- Maximum number of guaranteed coins to get in a "30 coins in 3 boxes" puzzle
- Interesting number theoretical game
- How do I show that if $\boldsymbol{a_1 a_2 a_3\cdots a_n \mid k}$ then each variable divides $\boldsymbol k $?
- Using only the digits 2,3,9, how many six-digit numbers can be formed which are divisible by 6?
- Algebra Proof including relative primes.
- How do I show that any natural number of this expression is a natural linear combination?
- Counting the number of solutions of the congruence $x^k\equiv h$ (mod q)
- algebraic integers of $x^4 -10x^2 +1$
- What exactly is the definition of Carmichael numbers?
- Number of divisors 888,888.
Related Questions in GCD-AND-LCM
- How do I show that if $\boldsymbol{a_1 a_2 a_3\cdots a_n \mid k}$ then each variable divides $\boldsymbol k $?
- GCD of common divisors in integral domain
- How do I solve this difficult gcd question?
- Fractions of the form $\frac{a}{k}\cdot\frac{b}{k}\cdot\frac{c}{k}\cdots=\frac{n}{k}$
- Why can't be a number the gcd of two numbers?
- Prove that if $\gcd(m, n) > 1$, then there do not exist integers $x, y$ so that $mx + ny = 1$.
- Least number of cuts to share sausages equally
- For $f \in \mathbb{Z}[x]$ , $\deg(\gcd_{\mathbb{Z}_q}(f, x^p - 1)) \geq \deg(\gcd_{\mathbb{Q}}(f, x^p - 1))$
- GCD as linear combination of two numbers
- A question regarding greatest common divisor
Trending Questions
- Induction on the number of equations
- How to convince a math teacher of this simple and obvious fact?
- Find $E[XY|Y+Z=1 ]$
- Refuting the Anti-Cantor Cranks
- What are imaginary numbers?
- Determine the adjoint of $\tilde Q(x)$ for $\tilde Q(x)u:=(Qu)(x)$ where $Q:U→L^2(Ω,ℝ^d$ is a Hilbert-Schmidt operator and $U$ is a Hilbert space
- Why does this innovative method of subtraction from a third grader always work?
- How do we know that the number $1$ is not equal to the number $-1$?
- What are the Implications of having VΩ as a model for a theory?
- Defining a Galois Field based on primitive element versus polynomial?
- Can't find the relationship between two columns of numbers. Please Help
- Is computer science a branch of mathematics?
- Is there a bijection of $\mathbb{R}^n$ with itself such that the forward map is connected but the inverse is not?
- Identification of a quadrilateral as a trapezoid, rectangle, or square
- Generator of inertia group in function field extension
Popular # Hahtags
second-order-logic
numerical-methods
puzzle
logic
probability
number-theory
winding-number
real-analysis
integration
calculus
complex-analysis
sequences-and-series
proof-writing
set-theory
functions
homotopy-theory
elementary-number-theory
ordinary-differential-equations
circles
derivatives
game-theory
definite-integrals
elementary-set-theory
limits
multivariable-calculus
geometry
algebraic-number-theory
proof-verification
partial-derivative
algebra-precalculus
Popular Questions
- What is the integral of 1/x?
- How many squares actually ARE in this picture? Is this a trick question with no right answer?
- Is a matrix multiplied with its transpose something special?
- What is the difference between independent and mutually exclusive events?
- Visually stunning math concepts which are easy to explain
- taylor series of $\ln(1+x)$?
- How to tell if a set of vectors spans a space?
- Calculus question taking derivative to find horizontal tangent line
- How to determine if a function is one-to-one?
- Determine if vectors are linearly independent
- What does it mean to have a determinant equal to zero?
- Is this Batman equation for real?
- How to find perpendicular vector to another vector?
- How to find mean and median from histogram
- How many sides does a circle have?
As fleablood commented, this is impossible if $m$ is even and $n$ is odd. I have three claims: (1) this is the only impossible case; (2) if $n \geq 2m$, then it is always possible to do in less than $n/m + 2$ operations when it is possible, and less than $n/m + 1$ if $n$ and $m$ are both even; and (3) if $n$ is even and $m = n-1$ (generalizing Ben Blum-Smith's example from the comments), then it requires exactly $n$ operations.
Proof of (1): This is trivial if $m = n$. Otherwise, we can flip two bits (say, $a$ and $b$) by first flipping $a$ along with $m-1$ others, and then flipping $b$ along with the same $m-1$ others. If we flip two bits at a time, the only obstruction we can run into is having an odd number $n$ of bits to flip to begin with. This problem is easily fixed if $m$ is odd (flip any $m$ bits initially), so the only bad case is when $n$ is odd and $m$ is even.
Proof of (2): Suppose $n \geq 2m$. Then we can modify the two-bit maneuver from above to flip any even number $2k \leq 2m$ of bits in exactly two moves. To do this, just flip $m$ bits first, and then flip another $m$ bits overlapping the previous ones in a set of size $m-k$. To flip all $n$ bits, then, begin by flipping $m$ bits from 0 to 1, and repeat this until the number of 0 bits remaining is an even number $2k \leq 2m$; then flip these as described. This algorithm flips $m-k < m$ bits three times rather than once, so the total number of flips is less than $n + 2m$, so the number of moves is less than $(n + 2m)/m = n/m + 2$.
Moreover, if $n$ and $m$ are both even, then we can even get away with less than $n/m + 1$. The reason is that the number of bits remaining is always even, so we can choose to apply the $2k$-bit maneuver when $m < 2k \leq 2m$, meaning that only $m-k < m/2$ bits are flipped three times, giving fewer than $(n+2(m/2))/m = n/m + 1$ moves in total.
Notice that this fact pins down the exact minimum number of moves needed. If $m$ and $n$ are both even, then the minimum number of moves needed is the unique integer in the range $[n/m, n/m+1)$. If $m$ is odd, then it's the unique integer in the range $[n/m, n/m+2)$ whose parity agrees with the parity of $n$.
Proof of (3): Take $n$ even and $m = n-1$. Then the only possible moves are to flip every bit except the $i$th one, where $1 \leq i \leq n$. By parity concerns, in order to flip every bit, we must do an even number of moves in total. But for every $i$, we must do moves other than the $i$th an odd number of times, because moves other than the $i$th are exactly what flip the $i$th bit. It follows that we must do the $i$th move an odd number of times (hence at least once) for every $i$, meaning that the shortest solution is to do the $i$th move exactly once for every $i$.