How many operations of flipping all brackets on a substring of a string of brackets are needed to make the string ‘correct’?

I call a string of brackets ‘correct’ if every opening bracket has a corresponding closing bracket somewhere after it and every closing bracket has a corresponding opening bracket somewhere before it. For example


is a correct string and


is an incorrect string.

An operation consists of taking a contiguous subsequence of the input string and ‘flipping’ every bracket in that subsequence.

Given an arbitrary string of brackets (of even length), the task is to find the smallest number of such operations needed to change it to a ‘correct’ string of brackets.

Another way to look at this problem is to have a string of +1s and -1s, and to try to find the smallest number of operations (of multiplying every number on an interval by -1) needed to make every prefix of this string nonnegative and every suffix nonpositive.

MonoGame – correct overloads for SpriteBatch.Draw flipping horizontally

I want to flip my sprite horizontally while drawing and I can’t figure out how to use the correct parameters without either an error or a warning about the method being obsolete.

This is what I assume it would be:

sb.Draw(NumbersGame.Arrow, resolutionRightArrow, Color.White, SpriteEffects.FlipHorizontally);

Except it comes up for errors for the color (cannot convert from color to rectangle) and the SpriteEffects bit (cannot convert from sprite effects to rectangle).

What is the correct way to lay out these arguments?

P.S: When I provide all the default values (says it’s obsolete): sb.Draw(NumbersGame.Arrow, resolutionRightArrow, null, null, null, 0f, null, Color.White, SpriteEffects.FlipHorizontally);

How to prove there are unreachable states in this bit flipping algorithm only for lengths $n=3k+2$?

This is similar to Bit flipping algorithm, but the algorithm is a little different. Specifically, we have bit string of length $ n$ , and we can choose any bit to flip and then we flip also the two surrounding bits, if there are any. So we can either flip three consecutive bits inside or flip the left-most/right-most two bits. For example for $ n=3$ we can draw transitions between states in a graph:

enter image description here

Now if we make a graph for $ n=2$ , the graph splits into two non-connected isomorphic sub-graphs as shown:

enter image description here

The same occurs for $ n=2,5,8,11,14$ , so I assume it holds for $ n=3k+2$ . For other $ n$ ‘s it is a graph with single connected component. Can we prove that the graph splits for $ n\equiv 2 \pmod 3$ ?

My attempts:

I was trying to find some attribute that is invariant for the bit flipping and show that there are two states with this attribute being different (for $ n=3k+2$ that is). This is easy for $ n=2$ case as we can see that bits parity is always preserved. However the same does not work for $ n=5$ : as an example there are two states such as $ 00100$ and $ 00010$ that cannot be reached from one another, but bits have the same parity. There is probably some simple argument for this, but I don’t see it.

By the way here is a Python code that can be used to generate such graphs, it requires graphviz:

length=5  def flip(N, bit):     pattern = 3 if bit == 0 else 7 << bit-1     return (N ^ pattern) & ((1 << length)-1)  def binary(n):     return format(n, '0%ib' % length)[::-1]  from graphviz import Graph dot = Graph()  for v1 in range(2**length):     for b in range(length):         v2 = flip(v1, b)         if v1 <= v2:             dot.edge(binary(v1),binary(v2),str(b+1)+".") dot.render('graph_complete%i' % length, view=True) 

What is the probability of flipping tail heads combination on two coins?

To find probability I should divide number of desired outcomes by total number of outcomes. So in this question I want TH (tail heads) combination out of two coins. What is the right way to get that probability and why?

It seems that there is three ways to calculate that probability. First one: desired outcome(TH)/possible outcomes(TT,HH,TH)=1/3. Second one: TH/(TT,HH,TH,HT)=1/4. From the last equation – if order doesn’t matter to me (TH=HT) – probability would be equal to 1/2. That problem arise from the fact that there is no way to distinguish TH from HT. How to solve this?

Sucker Bet – Coin Flipping Stochastic Process

Having a lot of trouble working out this exercise. I have tried constructing the 8×8 matrix with all possible combinations of three flips of the coin {HHH, HHT, HTH, … , TTT} and then calculating an exit distribution and trying to find the P(going to player 2’s strategy < going to player 1’s strategy) but I keep getting the 1 vector when solving. (Using the method out lined in Durrett of (I-r)^-1 * v = h). Any advice would be greatly appreciated.

[GET] Robert Charles – Phone Flipping Entrepreneurs

[GET] Robert Charles – Phone Flipping Entrepreneurs

Market price: $ 299

Author: Robert Charles

Phone Flipping Entrepreneurs
Are you an entrepreneur or do you have an entrepreneur mindset?

Have you tried building a business or starting a side hustle but can’t
seem to get it off the ground?

Do you understand the simple concept
of buy low and sell high?

If you answered yes to any of those questions,
you would become successful as a Phone Flipping Entrepreneur.
Using our proven…

[GET] Robert Charles – Phone Flipping Entrepreneurs

Friedlander-Iwaniec Flipping moduli

I am reading section 12 (Flipping Moduli) of the paper “The polynomial $ X^2+Y^4$ captures its primes” by Friedlander and Iwaniec.

At page 997, just below equation (12.7) we start estimating the following sum $ $ V(f,g)=\sum_d f(d)\sum_{\substack{r_1s_2\equiv r_2s_1 (d)\}} \alpha_{r_1,s_1}\bar{\alpha}_{r_2,s_2}\left(\frac{d}{r_1r_2}\right)g\left(\left|\frac{s_1}{r_1}-\frac{s_2}{r_2}\right|\right) $ $ where $ R\leq r\leq 2R$ , $ S\leq s\leq 2S$ and $ f$ is supported on $ \frac{1}{2}D\leq d\leq 3D$ . They start by reducing the variables $ r_1, r_2$ by the common divisor $ c=(r_1,r_2)$ and removing the resulting condition $ (c,d)=1$ (we know that both $ r_1$ and $ r_2$ are coprime to $ d$ , hence so is their gcd) by Mobius inversion, i.e. $ $ 1_{\text{gcd}(c,d)=1}=\sum_{m|\text{gcd}(c,d)}\mu(m) $ $ Using these tools we obtain equation (12.8) $ $ V(f,g)=\sum_c\sum_{m\mid c}\mu(m)V_{c,m})(f,g) $ $ where $ V_{c,m}(f,g)$ is defined as $ $ V_{c,m}(f,g)=\sum_d f(dm)\sum_{\substack{r_1s_2\equiv r_2s_1 (dm)\ (r_1,r_2)=1}}\alpha_{cr_1,s_1}\bar{\alpha}_{cr_2,s_2}\left(\frac{d}{r_1r_2}\right)g\left(\left|\frac{s_1}{r_1}-\frac{s_2}{r_2}\right|\right) $ $ They then proceed to obtain a bound for $ V_{c,m}(f,g)$ . After two pages they are able to prove the following bound (the inequality after equation (12.16)) \begin{equation} V_{c,m}(f,g)\ll\left\{(cm)^{-1/2}(DHRS)^{1/2}(2\log 2RS)^3 +\left[c^{-3/2}mD^{-1}(RS)^{3/2}+RS^{3/4}+SR^{3/4}\right](RS)^\epsilon\right\}\sum_{r,s}|\alpha_{cr,s}|^2 \end{equation} They then say that summing over this bound over $ m$ and $ c$ as in equation (12.8) yields $ $ V(f,g)\leq \mathcal{H}(D,H,R,S)\sum_r\sum_s\tau(r)|\alpha_{r,s}|^2 $ $ where $ \mathcal{H}(D,H,R,S)$ satisfies the bound \begin{multline} \mathcal{H}(D,H,R,S)\ll (DHRS)^{1/2}(\log 2RS)^4\ +\left[D^{-1}(RS)^{3/2}+RS^{3/4}+SR^{3/4}\right](RS)^\epsilon \end{multline} I am not able to understand how summing over $ m$ and $ c$ yields this bound. In particular what is the range over which $ c$ varies? I think it would suffices to prove the following bounds $ $ \sum_c\sum_{m\mid c}\mu(m)(cm)^{-1/2}\ll \log 2R $ $ and $ $ \sum_c\sum_{m\mid c}\mu(m)(c)^{-3/2}m\ll \log 2R $ $ I am able to show, using the multiplicativity of $ \mu$ that $ $ \sum_{m\mid c}\mu(m)m^{-1/2}\leq 1\qquad\text{ and }\qquad\sum_{m\mid c}\mu(m)m\leq c $ $ but I think that this estimation is too crude. In particular using such bound both equations reduce to showing that $ $ \sum_c c^{-1/2}\ll \log 2R $ $ but doesn’t look to be correct. Overall I don’t know if what I have done so far is correct and I should I proceed now. Thank you!