What is the expectation of the number of times a cycle is completely covered?

Consider a loop with a length of 1, then randomly select a continuous part in this loop with a length of 0.5 and cover it. Repeat this process for k times until the loop is completely covered. Find the mathematical expectation of k.

My personal thoughts are as follows.

I have personally considered the question for quite some time. I tried to disagree the question considering the possibility that the cycle is completely covered with 1,2,3 times of coverage, thinking of adding them to obtain the expectation of k later. When k = 1 and k = 2, obviously the probability is 0, when k = 3 the possibility can be shown by an image. Take the starting point of the first covered line segment as the reference point and, respectively, take the second and third covered line segments as x and y in a coordinate plane. We can trace the image as shown below.

As we create all possibilities, we can have this image. The shaded area is expressed when x lands at these specific points, where y should be to meet the requirements. When calculating the area of ​​the shadow, we can conclude that when k = 3, the probability that the loop is completely covered is 0.25

But when I started with the condition of k = 4, it implies a larger plot dimension, which is much more difficult, and I became unable to think clearly about that problem. Can anyone provide a new perspective on this problem? Or is there an elegant solution?

python: why the cycle doesn't want to start

The function asks a question, whose answer must be YES or NO. Take the text of the question and return the letter "y" or "n". I have a Python code, I need to transform it to Ruby.

#Python code 
def ask_yes_no(question):
   response = None
while response not in ("y", "n"):
   respone = input(question).lower()
return response

What did I do

# Ruby code
def ask_yes_no(question)

    guessed_it = false
    response = ""

    puts question
    loop do

        unless (response == ("y" || "n"))  || guessed_it

            response = gets.downcase
            return response #&& guessed_it == true


        break if guessed_it == true 

How is the weather?")

What is the polynomial cycle index for the trivial group?

CycleIndexPolynomial[Cycles[{}], {Subscript[x, 1]}]

returns 1.

I expected x_1.

Algorithm analysis: derives a while cycle (which apparently has some logarithmic traits) runs in $ Theta (n) $

I know for sure that the algorithm A run on $ Theta (n) $, but how is that derived?

Algorithm A

i = 1
while i ≤ n
  s = 0
  while s ≤ i
    s = s + 1
  i = 2 ∗ i

The inner loop is clearly $ O (i) $ (linear time).

The outer loop is clearly $ O ( log n) $ (logarithmic time).

A visualization of the loop in terms of an entry. $ n $ It would look as follows:

enter the description of the image here
, black lines represent the amount of work or iterations required in terms of $ n $.

algorithms: derive a while cycle in $ Theta ( sqrt {n}) $

I know for sure that the algorithm A run on $ Theta ( sqrt {n}) $, but how is that fact deduced?

Algorithm A

i = 0
s = 0
while s <= n:
    s += i
    i += 1

This is what I am thinking. We know A is limited by O (n), as we increase $ s $ by more than 1 in each iteration. We also know that you must be limited by $ log n $, as we increase $ s $ with something less than $ 2 ^ i $ in each iteration (Correct me if I am wrong, these are just my thoughts ...).

Now what else can we say about A? How do we deduce that its temporal complexity is $ Theta ( sqrt {n}) $?

Ice making cycle in ice cubes: everything else

The ice production cycle is controlled by a simple electrical circuit and several switches. In most ice machine designs, the water valve is located behind the refrigerator, but is connected to the central circuit through electrical wires. At the beginning of the cycle, the synchronized switch sends an electrical pulse to the solenoid valve.

The valve opens only for a few seconds so that the water fills the ice mold, which is usually a plastic container with several communicating cavities. As a general rule, these cavities have a semicircular curved shape. Each of the walls of the cavity has a small hole for the formation of an ice cube.

After completing the form, the water freezes. A built-in thermostat controls the temperature of the water in the mold. When the temperature drops to a certain value, the electric circuit breaker closes, as a result of which current is supplied to the heating coil below the ice maker. Heats the surface of the ice in contact with the mold to weaken its bond.

After that, the motor rotates a plastic shaft in which there are blades that push ice cubes from the mold to the storage tank. The shaft has a cam that lifts the handle of the switch when the ice cubes are pushed out of the mold, after which the handle goes down again and turns on the water valve. The cycle repeats. If the handle cannot open the water valve because the ice cubes in the storage tank interfere with it, the cycle is interrupted until the ice is removed from the storage tank. Ice from the ice maker, ice crushers are taken with a plastic spoon. Do not drink ice with your hands, glass or glass. Cocktail ice prepared in an ice machine, ice crusher or mill is placed in a refrigerator, an ice container or an ice cube.

In professional ice makers, a scheme is often also used in which the metal ice tray shape is vertically located (see Fig.)
Hot gas bypass pipe
Water Pump



structure of the bounded gender graphics cycle

Given fixed gender $ k $ There are some $ q = f (k) $ for which for any graph $ G $ of the bounded genre $ k $ exist $ q $ flat subgraphs $ G_1, G_2, .., G_q $ from $ G $
such that each cycle of $ G $ can be written as the symmetric difference of cycles in $ G_i $?
If true, what is a limit of $ f (k) $ Can a fixed (non-flat) inlay of $ G $ such that each $ G_i $ is flat?

Also posted here: https://math.stackexchange.com/questions/3349842/cycle-structure-of-bounded-genus-graphs
and https://mathoverflow.net/questions/339972/cycle-structure-of-bounded-genus-graphs
by the way, what stack exchange should I use to post graph theory type problems?

php: exclude products with a stock below the low stock threshold from the purchase cycle

On our Store page, we have several badges (such as "Series 1") that, when clicked on them, are linked to their respective product label pages. However, we also want a "low stock" badge. The problem is that we need to dynamically determine if something has little stock. We cannot simply label it.

I am linking the low stock logo to your own page with Woocommerce (products) shortcode, but now I just need to show those that have actions within that range. So far, the solutions I have found mention the elimination of products when making a taxonomy query, but I cannot do it, since I cannot assign them manually to a low stock label / category.

For reference, here is the taxonomy query that I have been using as a basis:

function custom_pre_get_posts_query( $q ) {
    if( is_shop() ) {
        $tag_query = (array) $q->get( 'tax_query' );

        $tag_query() = array(
               'taxonomy' => 'product_tag',
               'field' => 'slug',
               'terms' => array( 'retired' ), // Don't display products with the tag "retired"
               'operator' => 'NOT IN'

        $q->set( 'tax_query', $tag_query );
add_action( 'woocommerce_product_query', 'custom_pre_get_posts_query' );

java – Conditions in cycle for

In my function, what I do is fill a matrix with random numbers:

 public int()() llenarMatriz(int matriz()()) {

    for (int i = 0; i < matriz.length; i++) {

        for (int j = 0; j < matriz(j).length; j++) {

            matriz(i)(j) = (int) (Math.random() * 10);

    return matriz;


The matrix that passed by parameter is the following:

int matrizP()() = new int(2)(3);
matrizP = matriz.llenarMatriz(matrizP);

But what I don't understand is why he sends me the following error:

java.lang.ArrayIndexOutOfBoundsException: 2

What returns me matriz(j).length It will always be 3 in this case, I mean this is the condition that I use as a reference to not move to another position that does not exist.

Note that matriz(j).length where j increase to a maximum of 1, but when a cycle passes and the matriz( "aqui j seria 1" ).length but send the error of java.lang.ArrayIndexOutOfBoundsException: 2.

So I don't send this error I can put matriz(i).length I mean I change the iterator and everything is fixed, but I don't understand why you send that error with the iterator j Yes always

matriz("sea j o i ").length; //sera 3 en este caso.

In short, the problem is in the for nested bone the second for, and its condition as matriz(j).length, because with the iterator i it works but with the iterator j no.

I was thinking that: it must be that a cycle for You can only work with a condition that is immutable until you finish your cycle, that is, a cycle for It is not dynamic if you want to change the value of your condition parameter. I don't know if this is correct.

calculation and analysis – Cycle for an integral equation

I have a lot of equations. (All equations are a function of temperature now, but I will set a certain temperature for this calculation.) These will be constant in the last differential equation (dlscaleDtO2 (temp_)).

I need to update the initial value (lscale) with the value obtained by integrating the last equation for a short period of time. The obtained value must be kept updated during a loop calculation until the time reaches a certain value.

Does anyone have any ideas on this? I found many loop functions in the documentation, but it didn't help much. If you have any example similar to this, let me know. Thank you.

ClearAll("Global`*")(*clears all variable assignments*)
R = 8.31446; (*gas constant in J/mol*K *)
(Epsilon)o2 = 106.7;
(Epsilon)Ar = 93.3;
Tstar(temp_) = temp/Sqrt((Epsilon)o2*(Epsilon)Ar);
Tstar1(temp_) = temp/(Epsilon)Ar;
(CapitalOmega)o2(temp_) = 
  1.06036/Tstar(temp)^0.1561 + 0.193/Exp(0.47635*Tstar(temp)) + 
   1.03587/Exp(1.52996*Tstar(temp)) + 1.76474/Exp(3.89411*Tstar(temp));
(Gamma)Ar = 3.542;
(Gamma)o2ar = ((Gamma)Ar + 3.467)/2;
P = 1;(*total pressure in atm*)
Mo2 = 31.999;(*molar mass of O2 in g/mol*)
MAr = 39.948;(*molar mass of Ar in g/mol*)
Do2(temp_) = (
    Sqrt(1/Mo2 + 1/MAr))/((Gamma)o2ar^2*(CapitalOmega)o2(temp)*
(*Calculates the diffusivity as a function of temperature in m^2/s*)

(Rho)(temp_) = MAr/(0.0821*temp);
(Tau)(temp_) = 150.687/temp;
(Delta)(temp_) = (Rho)(temp)/13.40743*(1/39.948);

(CapitalOmega)ts(temp_) = 
  Exp((0.431*(Log(Tstar1(temp)))^0) - (0.4623*(Log(
        Tstar1(temp)))^1) + (0.08406*(Log(
        Tstar1(temp)))^2) + (0.005341*(Log(
        Tstar1(temp)))^3) - (0.00331*(Log(Tstar1(temp)))^4));

(Eta)o(temp_) = (

(Eta)r(temp_) = (12.19*(Tau)(temp)^0.42*(Delta)(temp)*
     Exp(0)) + (13.99*(Tau)(temp)^0*(Delta)(temp)^2*
     Exp(0)) + (0.005027*(Tau)(temp)^0.95*(Delta)(temp)^10*
     Exp(0)) - (18.93*(Tau)(temp)^0.5*(Delta)(temp)^5*
     Exp(-2)) - (6.698*(Tau)(temp)^0.9*(Delta)(temp)*
     Exp(-4)) - (3.827*(Tau)(temp)^0.8*(Delta)(temp)^2*Exp(-4));

(Eta)(temp_) = ((Eta)o(temp) + (Eta)r(temp))*10^-6;

lspec = 0.005;(*specimen length in m*)
v = Input(
  "Insert the velocity of the ambient gass in m/s", {});(*Prompts 
user to input for value*)
Nsco2(temp_) = (Eta)(temp)/((Rho)(temp)*Do2(temp));

Nre(temp_) = (Rho)(temp)*v*lspec/(Eta)(temp);

(Delta)blo2(temp_) = 
    2);(*calculates boundary layer thickness as a function of 
temperature in m units*)

Po2a = Input(
  "Insert the ambient o2 partial pressure in Pa", {});(*Prompts user 
to input for value*)

lscale = 0.000000001;(*arbitrary scale thickness in m*)

(CapitalPi)02scale(temp_) = 10^-12*Exp(-172998/(R*temp));
(*calculates the scale permiabillity as a function of temperature in 

Po2s(temp_) = (Do2(temp)*lscale*
     Po2a)/((Do2(temp)*lscale) + ((Delta)blo2(temp)*R*
        temp)));(*calculates the partial pressure of O2
at the scale surface as a function of temperature in Pa*)

Jo2scale(temp_) = (CapitalPi)02scale(temp)*(Po2s(temp)/lscale);

Jo2bl(temp_) = 
   Po2a - Po2s(temp))/(Delta)blo2(
    temp);(*calculates the flux through the boundary layer as a 
function of temperature*)

Vsic = 0.000012491;(*the value of the molar volume of SiC in m^3*)
Rsicrate(temp_) = (2*Vsic*
    temp))/3;(*calculates the recession rate of the SiC as a function 
of temperature*)

Msio = 44.085;
(Gamma)sioAR = (3.374 + (Gamma)Ar)/2;
(Epsilon)sio = 569;
Tstarsio(temp_) = temp/Sqrt((Epsilon)sio*(Epsilon)Ar);
(CapitalOmega)sio(temp_) = 
  1.06036/Tstarsio(temp)^0.1561 + 0.193/Exp(0.47635*Tstarsio(temp)) + 
   1.03587/Exp(1.52996*Tstarsio(temp)) + 1.76474/
Dsio(temp_) = (
    Sqrt(1/Msio + 1/MAr))/((Gamma)sioAR^2*(CapitalOmega)sio(temp)*

Msio2 = 60.084;
(Gamma)sio2AR = (3.706 + (Gamma)Ar)/2;
(Epsilon)sio2 = 2954;
Tstarsio2(temp_) = temp/Sqrt((Epsilon)sio2*(Epsilon)Ar);
(CapitalOmega)sio2(temp_) = 
  1.06036/Tstarsio2(temp)^0.1561 + 0.193/
   Exp(0.47635*Tstarsio2(temp)) + 1.03587/
   Exp(1.52996*Tstarsio2(temp)) + 1.76474/Exp(3.89411*Tstarsio2(temp));
Dsio2(temp_) = (
    Sqrt(1/Msio2 + 1/MAr))/((Gamma)sio2AR^2*(CapitalOmega)sio2(

Vsio2 = 0.000022673;(*the value of the molar volume of SiO2 in m^3*)

Nscsio2(temp_) = (Eta)(temp)/((Rho)(temp)*Dsio2(temp));

(Delta)blsio2(temp_) = 
    2);(*calculates boundary layer thickness as a function of 
temperature in m units*)

Nscsio(temp_) = (Eta)(temp)/((Rho)(temp)*Dsio(temp));
(Delta)blsio(temp_) = 
    2);(*calculates boundary layer thickness as a function of 
temperature in m units*)

CpO2(temp_) = 
  29.06356 - 0.0086*temp + 4.43955*10^-5*temp^2 - 
   4.80268*10^-8*temp^3 + 2.16311*10^-11*temp^4 - 
HO2(temp_) = Integrate(CpO2(temp), {temp, 298.15, temp});
SO2(temp_) = 205.15 + Integrate(CpO2(temp)/temp, {temp, 298.15, temp});
GO2(temp_) = HO2(temp) - temp*SO2(temp);

CpSiO(temp_) = 
  25.20453 + 0.01654*temp - 2.41133*10^-7*temp^2 - 
   1.18858*10^-8*temp^3 + 7.59597*10^-12*temp^4 - 
HSiO(temp_) = -100420 + Integrate(CpSiO(temp), {temp, 298.15, temp});
SSiO(temp_) = 
  211.58 + Integrate(CpSiO(temp)/temp, {temp, 298.15, temp});
GSiO(temp_) = HSiO(temp) - temp*SSiO(temp);

(CapitalDelta)GSiO(temp_) = GSiO(temp) + 1/2*GO2(temp) - GSiO2(temp);

KSiO(temp_) = 
  R*temp)); (*Equilibrium constant of SiO reaction (SiO2(s)(Rule) 
PSiOO2(temp_) = KSiO(temp)/Sqrt(
 Po2s(temp)); (*the partial pressure of SiO in equilibrium with the 
partial pressure of oxygen at the scale surface*)

JSiOvO2(temp_) = 
    temp);(*the SiO flux when only O2 exists*)

CpSiO2g(temp_) = 
  24.47298 + 0.09045*temp - 9.97765*10^-5*temp^2 + 
   5.89618*10^-8*temp^3 - 1.80209*10^-11*temp^4 + 
HSiO2g(temp_) = -305432 + 
   Integrate(CpSiO2g(temp), {temp, 298.15, temp});
SSiO2g(temp_) = 
  228.976 + Integrate(CpSiO2g(temp)/temp, {temp, 298.15, temp});
GSiO2g(temp_) = HSiO2g(temp) - temp*SSiO2g(temp);

(CapitalDelta)GSiO2g(temp_) = GSiO2g(temp) - GSiO2(temp);

KSiO2g(temp_) = 
  R*temp)); (*Equilibrium constant of SiO2 gasification (SiO2(s)
(Rule) SiO2(g)*)

PSiO2g(temp_) = 
 KSiO2g(temp); (*the partial pressure of evaporative SiO2 (SiO2(s)

JSiO2v(temp_) = 
   temp);(*the SiO2 flux when only O2 exists*)

dlscaleDtO2(temp_) = 
  2/3*Vsio2*Jo2scale(temp) - 
   Vsio2*(JSiOvO2(temp) + 
      JSiO2v(temp));(*Scale growth rate when only O2 exists*)