{
  "index": "2020-A-4",
  "type": "COMB",
  "tag": [
    "COMB",
    "NT",
    "ALG"
  ],
  "difficulty": "",
  "question": "Consider a horizontal strip of $N+2$ squares in which the first and the last square are black and the remaining $N$ squares are all white. Choose a white square uniformly at random, choose one of its two neighbors with equal probability,\nand color this neighboring square black if it is not already black. Repeat this process until all the remaining white squares have only black neighbors. Let $w(N)$ be the expected number of white squares remaining. Find\n\\[\n\\lim_{N \\to \\infty} \\frac{w(N)}{N}.\n\\]",
  "solution": "The answer is $1/e$. We first establish a recurrence for $w(N)$. Number the squares $1$ to $N+2$ from left to right. There are $2(N-1)$ equally likely events leading to the first new square being colored black: either we choose one of squares $3,\\ldots,N+1$ and color the square to its left, or we choose one of squares $2,\\ldots,N$ and color the square to its right. Thus the probability of square $i$ being the first new square colored black is $\\frac{1}{2(N-1)}$ if $i=2$ or $i=N+1$ and $\\frac{1}{N-1}$ if $3\\leq i\\leq N$. Once we have changed the first square $i$ from white to black, then the strip divides into two separate systems, squares $1$ through $i$ and squares $i$ through $N+2$, each with first and last square black and the rest white, and we can view the remaining process as continuing independently for each system. Thus if square $i$ is the first square to change color, the expected number of white squares at the end of the process is $w(i-2)+w(N+1-i)$. It follows that\n\\begin{align*}\nw(N) &= \\frac{1}{2(N-1)}(w(0)+w(N-1))+\\\\\n&\\quad \\frac{1}{N-1}\\left(\\sum_{i=3}^N (w(i-2)+w(N+1-i))\\right) \\\\\n&\\quad + \\frac{1}{2(N-1)}(w(N-1)+w(0))\n\\end{align*}\nand so \n\\[\n(N-1)w(N) = 2(w(1)+\\cdots+w(N-2))+w(N-1). \n\\]\nIf we replace $N$ by $N-1$ in this equation and subtract from the original equation, then we obtain the recurrence\n\\[\nw(N) = w(N-1)+\\frac{w(N-2)}{N-1}.\n\\]\n\nWe now claim that $w(N) = (N+1) \\sum_{k=0}^{N+1} \\frac{(-1)^k}{k!}$ for $N\\geq 0$. To prove this, we induct on $N$. The formula holds for $N=0$ and $N=1$ by inspection: $w(0)=0$ and $w(1)=1$. Now suppose that $N\\geq 2$ and $w(N-1) = N\\sum_{k=0}^N \\frac{(-1)^k}{k!}$, $w(N-2)=(N-1)\\sum_{k=0}^{N-1} \\frac{(-1)^k}{k!}$. Then\n\\begin{align*}\nw(N) &= w(N-1)+\\frac{w(N-2)}{N-1} \\\\\n&= N \\sum_{k=0}^N \\frac{(-1)^k}{k!} + \\sum_{k=0}^{N-1} \\frac{(-1)^k}{k!} \\\\\n& = (N+1) \\sum_{k=0}^{N-1} \\frac{(-1)^k}{k!}+\\frac{N(-1)^N}{N!}\\\\\n&= (N+1) \\sum_{k=0}^{N+1} \\frac{(-1)^k}{k!}\n\\end{align*}\nand the induction is complete.\n\nFinally, we compute that \n\\begin{align*}\n\\lim_{N\\to\\infty} \\frac{w(N)}{N} &= \\lim_{N\\to\\infty} \\frac{w(N)}{N+1} \\\\\n&= \\sum_{k=0}^\\infty \\frac{(-1)^k}{k!} = \\frac{1}{e}.\n\\end{align*}\n\n\\noindent\n\\textbf{Remark.}\nAoPS user pieater314159 suggests the following alternate description of $w(N)$. Consider the numbers $\\{1,\\dots,N+1\\}$ all originally colored white.\nChoose a permutation $\\pi \\in S_{N+1}$ uniformly at random. For $i=1,\\dots,N+1$ in succession, color $\\pi(i)$ black in case $\\pi(i+1)$ is currently white (regarding $i+1$ modulo $N+1$). After this, the expected number of white squares remaining is $w(N)$.\n\n\\noindent\n\\textbf{Remark.}\nAndrew Bernoff reports that this problem was inspired by a similar question of Jordan Ellenberg (disseminated via Twitter), which in turn was inspired by the final question of the 2017 MATHCOUNTS competition. See\n\\url{http://bit-player.org/2017/counting-your-chickens-before-theyre-pecked} for more discussion.",
  "vars": [
    "N",
    "w",
    "k",
    "i",
    "S",
    "\\\\pi"
  ],
  "params": [],
  "sci_consts": [
    "e"
  ],
  "variants": {
    "descriptive_long": {
      "map": {
        "N": "totalnodes",
        "w": "whiterem",
        "k": "indexvar",
        "i": "posindex",
        "S": "symmgroup",
        "\\pi": "permmap"
      },
      "question": "Consider a horizontal strip of $\\text{totalnodes}+2$ squares in which the first and the last square are black and the remaining $\\text{totalnodes}$ squares are all white. Choose a white square uniformly at random, choose one of its two neighbors with equal probability, and color this neighboring square black if it is not already black. Repeat this process until all the remaining white squares have only black neighbors. Let $\\text{whiterem}(\\text{totalnodes})$ be the expected number of white squares remaining. Find\n\\[\n\\lim_{\\text{totalnodes} \\to \\infty} \\frac{\\text{whiterem}(\\text{totalnodes})}{\\text{totalnodes}}.\n\\]",
      "solution": "The answer is $1/e$. We first establish a recurrence for $\\text{whiterem}(\\text{totalnodes})$. Number the squares $1$ to $\\text{totalnodes}+2$ from left to right. There are $2(\\text{totalnodes}-1)$ equally likely events leading to the first new square being colored black: either we choose one of squares $3,\\ldots,\\text{totalnodes}+1$ and color the square to its left, or we choose one of squares $2,\\ldots,\\text{totalnodes}$ and color the square to its right. Thus the probability of square $\\text{posindex}$ being the first new square colored black is $\\frac{1}{2(\\text{totalnodes}-1)}$ if $\\text{posindex}=2$ or $\\text{posindex}=\\text{totalnodes}+1$ and $\\frac{1}{\\text{totalnodes}-1}$ if $3\\leq \\text{posindex}\\leq \\text{totalnodes}$. Once we have changed the first square $\\text{posindex}$ from white to black, then the strip divides into two separate systems, squares $1$ through $\\text{posindex}$ and squares $\\text{posindex}$ through $\\text{totalnodes}+2$, each with first and last square black and the rest white, and we can view the remaining process as continuing independently for each system. Thus if square $\\text{posindex}$ is the first square to change color, the expected number of white squares at the end of the process is $\\text{whiterem}(\\text{posindex}-2)+\\text{whiterem}(\\text{totalnodes}+1-\\text{posindex})$. It follows that\n\\begin{align*}\n\\text{whiterem}(\\text{totalnodes}) &= \\frac{1}{2(\\text{totalnodes}-1)}\\bigl(\\text{whiterem}(0)+\\text{whiterem}(\\text{totalnodes}-1)\\bigr)+\\\\\n&\\quad \\frac{1}{\\text{totalnodes}-1}\\left(\\sum_{\\text{posindex}=3}^{\\text{totalnodes}} \\bigl(\\text{whiterem}(\\text{posindex}-2)+\\text{whiterem}(\\text{totalnodes}+1-\\text{posindex})\\bigr)\\right) \\\\\n&\\quad + \\frac{1}{2(\\text{totalnodes}-1)}\\bigl(\\text{whiterem}(\\text{totalnodes}-1)+\\text{whiterem}(0)\\bigr)\n\\end{align*}\nand so \n\\[\n(\\text{totalnodes}-1)\\text{whiterem}(\\text{totalnodes}) = 2\\bigl(\\text{whiterem}(1)+\\cdots+\\text{whiterem}(\\text{totalnodes}-2)\\bigr)+\\text{whiterem}(\\text{totalnodes}-1).\n\\]\nIf we replace $\\text{totalnodes}$ by $\\text{totalnodes}-1$ in this equation and subtract from the original equation, then we obtain the recurrence\n\\[\n\\text{whiterem}(\\text{totalnodes}) = \\text{whiterem}(\\text{totalnodes}-1)+\\frac{\\text{whiterem}(\\text{totalnodes}-2)}{\\text{totalnodes}-1}.\n\\]\n\nWe now claim that $\\text{whiterem}(\\text{totalnodes}) = (\\text{totalnodes}+1) \\sum_{\\text{indexvar}=0}^{\\text{totalnodes}+1} \\frac{(-1)^{\\text{indexvar}}}{\\text{indexvar}!}$ for $\\text{totalnodes}\\geq 0$. To prove this, we induct on $\\text{totalnodes}$. The formula holds for $\\text{totalnodes}=0$ and $\\text{totalnodes}=1$ by inspection: $\\text{whiterem}(0)=0$ and $\\text{whiterem}(1)=1$. Now suppose that $\\text{totalnodes}\\geq 2$ and $\\text{whiterem}(\\text{totalnodes}-1) = \\text{totalnodes}\\sum_{\\text{indexvar}=0}^{\\text{totalnodes}} \\frac{(-1)^{\\text{indexvar}}}{\\text{indexvar}!}$, $\\text{whiterem}(\\text{totalnodes}-2)=(\\text{totalnodes}-1)\\sum_{\\text{indexvar}=0}^{\\text{totalnodes}-1} \\frac{(-1)^{\\text{indexvar}}}{\\text{indexvar}!}$. Then\n\\begin{align*}\n\\text{whiterem}(\\text{totalnodes}) &= \\text{whiterem}(\\text{totalnodes}-1)+\\frac{\\text{whiterem}(\\text{totalnodes}-2)}{\\text{totalnodes}-1} \\\\\n&= \\text{totalnodes} \\sum_{\\text{indexvar}=0}^{\\text{totalnodes}} \\frac{(-1)^{\\text{indexvar}}}{\\text{indexvar}!} + \\sum_{\\text{indexvar}=0}^{\\text{totalnodes}-1} \\frac{(-1)^{\\text{indexvar}}}{\\text{indexvar}!} \\\\\n& = (\\text{totalnodes}+1) \\sum_{\\text{indexvar}=0}^{\\text{totalnodes}-1} \\frac{(-1)^{\\text{indexvar}}}{\\text{indexvar}!}+\\frac{\\text{totalnodes}(-1)^{\\text{totalnodes}}}{\\text{totalnodes}!}\\\\\n&= (\\text{totalnodes}+1) \\sum_{\\text{indexvar}=0}^{\\text{totalnodes}+1} \\frac{(-1)^{\\text{indexvar}}}{\\text{indexvar}!}\n\\end{align*}\nand the induction is complete.\n\nFinally, we compute that \n\\begin{align*}\n\\lim_{\\text{totalnodes}\\to\\infty} \\frac{\\text{whiterem}(\\text{totalnodes})}{\\text{totalnodes}} &= \\lim_{\\text{totalnodes}\\to\\infty} \\frac{\\text{whiterem}(\\text{totalnodes})}{\\text{totalnodes}+1} \\\\\n&= \\sum_{\\text{indexvar}=0}^\\infty \\frac{(-1)^{\\text{indexvar}}}{\\text{indexvar}!} = \\frac{1}{e}.\n\\end{align*}\n\n\\noindent\n\\textbf{Remark.}\nAoPS user pieater314159 suggests the following alternate description of $\\text{whiterem}(\\text{totalnodes})$. Consider the numbers $\\{1,\\dots,\\text{totalnodes}+1\\}$ all originally colored white.\nChoose a permutation $\\text{permmap} \\in \\text{symmgroup}_{\\text{totalnodes}+1}$ uniformly at random. For $\\text{posindex}=1,\\dots,\\text{totalnodes}+1$ in succession, color $\\text{permmap}(\\text{posindex})$ black in case $\\text{permmap}(\\text{posindex}+1)$ is currently white (regarding $\\text{posindex}+1$ modulo $\\text{totalnodes}+1$). After this, the expected number of white squares remaining is $\\text{whiterem}(\\text{totalnodes})$.\n\n\\noindent\n\\textbf{Remark.}\nAndrew Bernoff reports that this problem was inspired by a similar question of Jordan Ellenberg (disseminated via Twitter), which in turn was inspired by the final question of the 2017 MATHCOUNTS competition. See\n\\url{http://bit-player.org/2017/counting-your-chickens-before-theyre-pecked} for more discussion."
    },
    "descriptive_long_confusing": {
      "map": {
        "N": "sunshine",
        "w": "umbrella",
        "k": "giraffes",
        "i": "volcano",
        "S": "hammock",
        "\\pi": "stapler"
      },
      "question": "Consider a horizontal strip of $sunshine+2$ squares in which the first and the last square are black and the remaining $sunshine$ squares are all white. Choose a white square uniformly at random, choose one of its two neighbors with equal probability,\nand color this neighboring square black if it is not already black. Repeat this process until all the remaining white squares have only black neighbors. Let $umbrella(sunshine)$ be the expected number of white squares remaining. Find\n\\[\n\\lim_{sunshine \\to \\infty} \\frac{umbrella(sunshine)}{sunshine}.\n\\]",
      "solution": "The answer is $1/e$. We first establish a recurrence for $umbrella(sunshine)$. Number the squares $1$ to $sunshine+2$ from left to right. There are $2(sunshine-1)$ equally likely events leading to the first new square being colored black: either we choose one of squares $3,\\ldots,sunshine+1$ and color the square to its left, or we choose one of squares $2,\\ldots,sunshine$ and color the square to its right. Thus the probability of square $volcano$ being the first new square colored black is $\\frac{1}{2(sunshine-1)}$ if $volcano=2$ or $volcano=sunshine+1$ and $\\frac{1}{sunshine-1}$ if $3\\leq volcano\\leq sunshine$. Once we have changed the first square $volcano$ from white to black, then the strip divides into two separate systems, squares $1$ through $volcano$ and squares $volcano$ through $sunshine+2$, each with first and last square black and the rest white, and we can view the remaining process as continuing independently for each system. Thus if square $volcano$ is the first square to change color, the expected number of white squares at the end of the process is $umbrella(volcano-2)+umbrella(sunshine+1-volcano)$. It follows that\n\\begin{align*}\numbrella(sunshine) &= \\frac{1}{2(sunshine-1)}(umbrella(0)+umbrella(sunshine-1))+\\\\\n&\\quad \\frac{1}{sunshine-1}\\left(\\sum_{volcano=3}^{sunshine} (umbrella(volcano-2)+umbrella(sunshine+1-volcano))\\right) \\\\\n&\\quad + \\frac{1}{2(sunshine-1)}(umbrella(sunshine-1)+umbrella(0))\n\\end{align*}\nand so \n\\[\n(sunshine-1) \\, umbrella(sunshine) = 2(umbrella(1)+\\cdots+umbrella(sunshine-2))+umbrella(sunshine-1). \n\\]\nIf we replace $sunshine$ by $sunshine-1$ in this equation and subtract from the original equation, then we obtain the recurrence\n\\[\num brella(sunshine) = umbrella(sunshine-1)+\\frac{umbrella(sunshine-2)}{sunshine-1}.\n\\]\n\nWe now claim that $umbrella(sunshine) = (sunshine+1) \\sum_{giraffes=0}^{sunshine+1} \\frac{(-1)^{giraffes}}{giraffes!}$ for $sunshine\\geq 0$. To prove this, we induct on $sunshine$. The formula holds for $sunshine=0$ and $sunshine=1$ by inspection: $umbrella(0)=0$ and $umbrella(1)=1$. Now suppose that $sunshine\\geq 2$ and $umbrella(sunshine-1) = sunshine\\sum_{giraffes=0}^{sunshine} \\frac{(-1)^{giraffes}}{giraffes!}$, $umbrella(sunshine-2)=(sunshine-1)\\sum_{giraffes=0}^{sunshine-1} \\frac{(-1)^{giraffes}}{giraffes!}$. Then\n\\begin{align*}\numbrella(sunshine) &= umbrella(sunshine-1)+\\frac{umbrella(sunshine-2)}{sunshine-1} \\\\\n&= sunshine \\sum_{giraffes=0}^{sunshine} \\frac{(-1)^{giraffes}}{giraffes!} + \\sum_{giraffes=0}^{sunshine-1} \\frac{(-1)^{giraffes}}{giraffes!} \\\\\n& = (sunshine+1) \\sum_{giraffes=0}^{sunshine-1} \\frac{(-1)^{giraffes}}{giraffes!}+\\frac{sunshine(-1)^{sunshine}}{sunshine!}\\\\\n&= (sunshine+1) \\sum_{giraffes=0}^{sunshine+1} \\frac{(-1)^{giraffes}}{giraffes!}\n\\end{align*}\nand the induction is complete.\n\nFinally, we compute that \n\\begin{align*}\n\\lim_{sunshine\\to\\infty} \\frac{umbrella(sunshine)}{sunshine} &= \\lim_{sunshine\\to\\infty} \\frac{umbrella(sunshine)}{sunshine+1} \\\\\n&= \\sum_{giraffes=0}^\\infty \\frac{(-1)^{giraffes}}{giraffes!} = \\frac{1}{e}.\n\\end{align*}\n\n\\noindent\n\\textbf{Remark.}\nAoPS user pieater314159 suggests the following alternate description of $umbrella(sunshine)$. Consider the numbers $\\{1,\\dots,sunshine+1\\}$ all originally colored white.\nChoose a permutation $stapler \\in hammock_{sunshine+1}$ uniformly at random. For $volcano=1,\\dots,sunshine+1$ in succession, color $stapler(volcano)$ black in case $stapler(volcano+1)$ is currently white (regarding $volcano+1$ modulo $sunshine+1$). After this, the expected number of white squares remaining is $umbrella(sunshine)$.\n\n\\noindent\n\\textbf{Remark.}\nAndrew Bernoff reports that this problem was inspired by a similar question of Jordan Ellenberg (disseminated via Twitter), which in turn was inspired by the final question of the 2017 MATHCOUNTS competition. See\n\\url{http://bit-player.org/2017/counting-your-chickens-before-theyre-pecked} for more discussion."
    },
    "descriptive_long_misleading": {
      "map": {
        "N": "tinycount",
        "w": "blackness",
        "k": "fullrange",
        "i": "entirepos",
        "S": "asymgroup",
        "\\pi": "staticelem"
      },
      "question": "Consider a horizontal strip of $tinycount+2$ squares in which the first and the last square are black and the remaining $tinycount$ squares are all white. Choose a white square uniformly at random, choose one of its two neighbors with equal probability,\nand color this neighboring square black if it is not already black. Repeat this process until all the remaining white squares have only black neighbors. Let $\\blackness(tinycount)$ be the expected number of white squares remaining. Find\n\\[\n\\lim_{tinycount \\to \\infty} \\frac{\\blackness(tinycount)}{tinycount}.\n\\]",
      "solution": "The answer is $1/e$. We first establish a recurrence for $\\blackness(tinycount)$. Number the squares $1$ to $tinycount+2$ from left to right. There are $2(tinycount-1)$ equally likely events leading to the first new square being colored black: either we choose one of squares $3,\\ldots,tinycount+1$ and color the square to its left, or we choose one of squares $2,\\ldots,tinycount$ and color the square to its right. Thus the probability of square $entirepos$ being the first new square colored black is $\\frac{1}{2(tinycount-1)}$ if $entirepos=2$ or $entirepos=tinycount+1$ and $\\frac{1}{tinycount-1}$ if $3\\leq entirepos\\leq tinycount$. Once we have changed the first square $entirepos$ from white to black, then the strip divides into two separate systems, squares $1$ through $entirepos$ and squares $entirepos$ through $tinycount+2$, each with first and last square black and the rest white, and we can view the remaining process as continuing independently for each system. Thus if square $entirepos$ is the first square to change color, the expected number of white squares at the end of the process is $\\blackness(entirepos-2)+\\blackness(tinycount+1-entirepos)$. It follows that\n\\begin{align*}\n\\blackness(tinycount) &= \\frac{1}{2(tinycount-1)}(\\blackness(0)+\\blackness(tinycount-1))+\\\\\n&\\quad \\frac{1}{tinycount-1}\\left(\\sum_{entirepos=3}^{tinycount} (\\blackness(entirepos-2)+\\blackness(tinycount+1-entirepos))\\right) \\\\&\\quad + \\frac{1}{2(tinycount-1)}(\\blackness(tinycount-1)+\\blackness(0))\n\\end{align*}\nand so \n\\[\n(tinycount-1)\\blackness(tinycount) = 2(\\blackness(1)+\\cdots+\\blackness(tinycount-2))+\\blackness(tinycount-1). \n\\]\nIf we replace $tinycount$ by $tinycount-1$ in this equation and subtract from the original equation, then we obtain the recurrence\n\\[\n\\blackness(tinycount) = \\blackness(tinycount-1)+\\frac{\\blackness(tinycount-2)}{tinycount-1}.\n\\]\n\nWe now claim that $\\blackness(tinycount) = (tinycount+1) \\sum_{fullrange=0}^{tinycount+1} \\frac{(-1)^{fullrange}}{fullrange!}$ for $tinycount\\geq 0$. To prove this, we induct on $tinycount$. The formula holds for $tinycount=0$ and $tinycount=1$ by inspection: $\\blackness(0)=0$ and $\\blackness(1)=1$. Now suppose that $tinycount\\geq 2$ and $\\blackness(tinycount-1) = tinycount\\sum_{fullrange=0}^{tinycount} \\frac{(-1)^{fullrange}}{fullrange!}$, $\\blackness(tinycount-2)=(tinycount-1)\\sum_{fullrange=0}^{tinycount-1} \\frac{(-1)^{fullrange}}{fullrange!}$. Then\n\\begin{align*}\n\\blackness(tinycount) &= \\blackness(tinycount-1)+\\frac{\\blackness(tinycount-2)}{tinycount-1} \\\\&= tinycount \\sum_{fullrange=0}^{tinycount} \\frac{(-1)^{fullrange}}{fullrange!} + \\sum_{fullrange=0}^{tinycount-1} \\frac{(-1)^{fullrange}}{fullrange!} \\\\& = (tinycount+1) \\sum_{fullrange=0}^{tinycount-1} \\frac{(-1)^{fullrange}}{fullrange!}+\\frac{tinycount(-1)^{tinycount}}{tinycount!}\\\\&= (tinycount+1) \\sum_{fullrange=0}^{tinycount+1} \\frac{(-1)^{fullrange}}{fullrange!}\n\\end{align*}\nand the induction is complete.\n\nFinally, we compute that \n\\begin{align*}\n\\lim_{tinycount\\to\\infty} \\frac{\\blackness(tinycount)}{tinycount} &= \\lim_{tinycount\\to\\infty} \\frac{\\blackness(tinycount)}{tinycount+1} \\\\&= \\sum_{fullrange=0}^\\infty \\frac{(-1)^{fullrange}}{fullrange!} = \\frac{1}{e}.\n\\end{align*}\n\n\\noindent\n\\textbf{Remark.}\nAoPS user pieater314159 suggests the following alternate description of $\\blackness(tinycount)$. Consider the numbers $\\{1,\\dots,tinycount+1\\}$ all originally colored white.\nChoose a permutation $staticelem \\in asymgroup_{tinycount+1}$ uniformly at random. For $entirepos=1,\\dots,tinycount+1$ in succession, color $staticelem(entirepos)$ black in case $staticelem(entirepos+1)$ is currently white (regarding $entirepos+1$ modulo $tinycount+1$). After this, the expected number of white squares remaining is $\\blackness(tinycount)$.\n\n\\noindent\n\\textbf{Remark.}\nAndrew Bernoff reports that this problem was inspired by a similar question of Jordan Ellenberg (disseminated via Twitter), which in turn was inspired by the final question of the 2017 MATHCOUNTS competition. See\n\\url{http://bit-player.org/2017/counting-your-chickens-before-theyre-pecked} for more discussion."
    },
    "garbled_string": {
      "map": {
        "N": "xmsklneda",
        "w": "qzxwvtnpf",
        "k": "hjgrkslab",
        "S": "vbmnclkra"
      },
      "question": "Consider a horizontal strip of $xmsklneda+2$ squares in which the first and the last square are black and the remaining $xmsklneda$ squares are all white. Choose a white square uniformly at random, choose one of its two neighbors with equal probability,\nand color this neighboring square black if it is not already black. Repeat this process until all the remaining white squares have only black neighbors. Let $qzxwvtnpf(xmsklneda)$ be the expected number of white squares remaining. Find\n\\[\n\\lim_{xmsklneda \\to \\infty} \\frac{qzxwvtnpf(xmsklneda)}{xmsklneda}.\n\\]",
      "solution": "The answer is $1/e$. We first establish a recurrence for $qzxwvtnpf(xmsklneda)$. Number the squares $1$ to $xmsklneda+2$ from left to right. There are $2(xmsklneda-1)$ equally likely events leading to the first new square being colored black: either we choose one of squares $3,\\ldots,xmsklneda+1$ and color the square to its left, or we choose one of squares $2,\\ldots,xmsklneda$ and color the square to its right. Thus the probability of square $i$ being the first new square colored black is $\\frac{1}{2(xmsklneda-1)}$ if $i=2$ or $i=xmsklneda+1$ and $\\frac{1}{xmsklneda-1}$ if $3\\leq i\\leq xmsklneda$. Once we have changed the first square $i$ from white to black, then the strip divides into two separate systems, squares $1$ through $i$ and squares $i$ through $xmsklneda+2$, each with first and last square black and the rest white, and we can view the remaining process as continuing independently for each system. Thus if square $i$ is the first square to change color, the expected number of white squares at the end of the process is $qzxwvtnpf(i-2)+qzxwvtnpf(xmsklneda+1-i)$. It follows that\n\\begin{align*}\nqzxwvtnpf(xmsklneda) &= \\frac{1}{2(xmsklneda-1)}(qzxwvtnpf(0)+qzxwvtnpf(xmsklneda-1))+\\\\\n&\\quad \\frac{1}{xmsklneda-1}\\left(\\sum_{i=3}^{xmsklneda} (qzxwvtnpf(i-2)+qzxwvtnpf(xmsklneda+1-i))\\right) \\\\\n&\\quad + \\frac{1}{2(xmsklneda-1)}(qzxwvtnpf(xmsklneda-1)+qzxwvtnpf(0))\n\\end{align*}\nand so \n\\[\n(xmsklneda-1)qzxwvtnpf(xmsklneda) = 2(qzxwvtnpf(1)+\\cdots+qzxwvtnpf(xmsklneda-2))+qzxwvtnpf(xmsklneda-1). \n\\]\nIf we replace $xmsklneda$ by $xmsklneda-1$ in this equation and subtract from the original equation, then we obtain the recurrence\n\\[\nqzxwvtnpf(xmsklneda) = qzxwvtnpf(xmsklneda-1)+\\frac{qzxwvtnpf(xmsklneda-2)}{xmsklneda-1}.\n\\]\n\nWe now claim that $qzxwvtnpf(xmsklneda) = (xmsklneda+1) \\sum_{hjgrkslab=0}^{xmsklneda+1} \\frac{(-1)^{hjgrkslab}}{hjgrkslab!}$ for $xmsklneda\\geq 0$. To prove this, we induct on $xmsklneda$. The formula holds for $xmsklneda=0$ and $xmsklneda=1$ by inspection: $qzxwvtnpf(0)=0$ and $qzxwvtnpf(1)=1$. Now suppose that $xmsklneda\\geq 2$ and $qzxwvtnpf(xmsklneda-1) = xmsklneda\\sum_{hjgrkslab=0}^{xmsklneda} \\frac{(-1)^{hjgrkslab}}{hjgrkslab!}$, $qzxwvtnpf(xmsklneda-2)=(xmsklneda-1)\\sum_{hjgrkslab=0}^{xmsklneda-1} \\frac{(-1)^{hjgrkslab}}{hjgrkslab!}$. Then\n\\begin{align*}\nqzxwvtnpf(xmsklneda) &= qzxwvtnpf(xmsklneda-1)+\\frac{qzxwvtnpf(xmsklneda-2)}{xmsklneda-1} \\\\\n&= xmsklneda \\sum_{hjgrkslab=0}^{xmsklneda} \\frac{(-1)^{hjgrkslab}}{hjgrkslab!} + \\sum_{hjgrkslab=0}^{xmsklneda-1} \\frac{(-1)^{hjgrkslab}}{hjgrkslab!} \\\\\n& = (xmsklneda+1) \\sum_{hjgrkslab=0}^{xmsklneda-1} \\frac{(-1)^{hjgrkslab}}{hjgrkslab!}+\\frac{xmsklneda(-1)^{xmsklneda}}{xmsklneda!}\\\\\n&= (xmsklneda+1) \\sum_{hjgrkslab=0}^{xmsklneda+1} \\frac{(-1)^{hjgrkslab}}{hjgrkslab!}\n\\end{align*}\nand the induction is complete.\n\nFinally, we compute that \n\\begin{align*}\n\\lim_{xmsklneda\\to\\infty} \\frac{qzxwvtnpf(xmsklneda)}{xmsklneda} &= \\lim_{xmsklneda\\to\\infty} \\frac{qzxwvtnpf(xmsklneda)}{xmsklneda+1} \\\\\n&= \\sum_{hjgrkslab=0}^{\\infty} \\frac{(-1)^{hjgrkslab}}{hjgrkslab!} = \\frac{1}{e}.\n\\end{align*}\n\n\\noindent\n\\textbf{Remark.}\nAoPS user pieater314159 suggests the following alternate description of $qzxwvtnpf(xmsklneda)$. Consider the numbers $\\{1,\\dots,xmsklneda+1\\}$ all originally colored white.\nChoose a permutation $\\pi \\in vbmnclkra_{xmsklneda+1}$ uniformly at random. For $i=1,\\dots,xmsklneda+1$ in succession, color $\\pi(i)$ black in case $\\pi(i+1)$ is currently white (regarding $i+1$ modulo $xmsklneda+1$). After this, the expected number of white squares remaining is $qzxwvtnpf(xmsklneda)$.\n\n\\noindent\n\\textbf{Remark.}\nAndrew Bernoff reports that this problem was inspired by a similar question of Jordan Ellenberg (disseminated via Twitter), which in turn was inspired by the final question of the 2017 MATHCOUNTS competition. See\n\\url{http://bit-player.org/2017/counting-your-chickens-before-theyre-pecked} for more discussion."
    },
    "kernel_variant": {
      "question": "Let $p$ be a fixed real number with $0<p<1$ and set $q:=1-p$.  \nFor every non–negative integer $N$ place $N+4$ unit squares in one row and colour the four\n“sentinel’’ squares  \n\\[\n1,\\;2,\\;N+3,\\;N+4\n\\]\nblack, leaving the $N$ squares $3,4,\\dots ,N+2$ white.\n\nRepeatedly perform the following random experiment until no two adjacent squares are\nsimultaneously white.\n\n(1) From all \\emph{ordered} adjacent white pairs $(x,x+1)$ choose one uniformly at random.  \n\n(2) Having chosen $(x,x+1)$, colour $x$ black with probability $p$ and\n$x+1$ black with probability $q$.\n\nLet $w(N)$ be the expected number of white squares that remain when the procedure stops\n(conventions: $w(0)=0$, $w(1)=1$ because for $N=0,1$ no move is possible).\n\n(a)  Show that for $N\\ge 2$\n\\[\nw(N)=w(N-1)+\\frac{w(N-2)}{N-1}.\n\\tag{R}\n\\]\n\n(b)  Prove the closed formula\n\\[\nw(N)=(N+1)\\sum_{k=0}^{N+1}\\frac{(-1)^k}{k!}\\qquad(N\\ge 0).\n\\tag{F}\n\\]\n\n(c)  Deduce the complete first–order asymptotics\n\\[\n\\frac{w(N)}{N}= \\frac{1}{e}+\\frac{1}{eN}+O\\!\\Bigl(\\tfrac{1}{(N+1)!}\\Bigr)\n\\qquad(N\\to\\infty),\n\\]\nand in particular\n\\[\n\\lim_{N\\to\\infty}\\frac{w(N)}{N}=\\frac{1}{e},\\qquad\n\\lim_{N\\to\\infty}\\!\\Bigl(w(N)-\\tfrac{N}{e}\\Bigr)=\\frac{1}{e}.\n\\]\n\nYour answers must be independent of $p$.",
      "solution": "Throughout we abbreviate $q:=1-p$ and write  \n\\[\nS(N):=\\sum_{j=0}^{N} w(j)\\qquad(N\\ge 0).\n\\]\n\n\\textbf{Step 1.  Probabilities for the first square that turns black.}  \nRelabel the $N$ initially white squares as $1,2,\\dots ,N$; square $1$ is the\nformer square $3$, etc.  The $(N-1)$ ordered adjacent white pairs are\n\\[\n(1,2),\\,(2,3),\\dots ,(N-1,N).\n\\]\nIf pair $(i,i+1)$ is chosen, square $i$ becomes black with probability $p$\nand $i+1$ with probability $q$.  Hence  \n\\[\n\\Pr(\\text{first black square}=1)=\\frac{p}{N-1},\\qquad\n\\Pr(\\text{first black square}=N)=\\frac{q}{N-1},\n\\]\nand for $2\\le i\\le N-1$\n\\[\n\\Pr(\\text{first black square}=i)=\\frac{1}{N-1}.\n\\tag{1}\n\\]\n\n\\textbf{Step 2.  Splitting after the first colouring.}  \nIf $i$ is the first square to be coloured black, the configuration decomposes\ninto\n\\[\n\\underbrace{\\boxed{\\phantom{\\small 1}}\\dots\\boxed{\\phantom{\\small 1}}}_{i-1\n  \\text{ white squares}}\\qquad\\text{and}\\qquad\n\\underbrace{\\boxed{\\phantom{\\small 1}}\\dots\\boxed{\\phantom{\\small 1}}}_{N-i\n  \\text{ white squares}},\n\\]\neach bracketed by black sentinels at both ends.  \nBy \\emph{additivity of expectation} (independence is not required) the expected\nfinal number of white squares equals the sum of the expectations for the two\nsubsystems.  Therefore\n\\[\nw(N)=\\sum_{i=1}^{N} \\Pr(\\text{first}=i)\\,\n      \\bigl(w(i-1)+w(N-i)\\bigr).\n\\tag{2}\n\\]\n\n\\textbf{Step 3.  A $p$–free recurrence.}  \nInsert (1) into (2).  The two extreme squares occur only once,\nall interior squares twice.  One finds\n\\[\n(N-1)w(N)=w(N-1)+2\\sum_{j=1}^{N-2}w(j)=w(N-1)+2S(N-2),\n\\]\nhence\n\\[\nw(N)-w(N-1)=\\frac{w(N-2)}{N-1}\\qquad(N\\ge 2),\n\\]\nwhich is exactly the required recurrence (R).  Observe that the parameter $p$\nhas disappeared completely.\n\n\\textbf{Step 4.  Solving the recurrence.}  \n\\emph{Claim:} formula (F) holds for every $N\\ge 0$.  \n\n\\emph{Proof by induction.}  \nBase cases $N=0,1$ are immediate: $w(0)=0$ and $w(1)=1$ match (F).\nAssume $w(N-1)=f_{N-1}$ and $w(N-2)=f_{N-2}$ with\n\\[\nf_{m}:=(m+1)\\sum_{k=0}^{m+1}\\frac{(-1)^k}{k!}\\quad(m\\ge 0).\n\\]\nUsing (R) it suffices to verify\n\\[\nf_{N}-f_{N-1}=\\frac{f_{N-2}}{\\,N-1}.\n\\tag{3}\n\\]\nCompute\n\\[\n\\begin{aligned}\nf_{N}-f_{N-1}\n&=(N+1)\\sum_{k=0}^{N+1}\\frac{(-1)^k}{k!}\n   -N\\sum_{k=0}^{N}\\frac{(-1)^k}{k!}\\\\\n&=\\sum_{k=0}^{N-1}\\frac{(-1)^k}{k!},\n\\end{aligned}\n\\]\nwhile\n\\[\n\\frac{f_{N-2}}{N-1}\n   =\\sum_{k=0}^{N-1}\\frac{(-1)^k}{k!}.\n\\]\nEquality (3) holds, completing the induction and proving (F).\n\n\\textbf{Step 5.  Precise asymptotics.}  \nWrite $E_{N}:=\\displaystyle\\sum_{k=0}^{N}\\frac{(-1)^k}{k!}$ and \n\\[\nR_{N+1}:=e^{-1}-E_{N+1}\\qquad(N\\ge 0).\n\\]\nBecause the exponential series is alternating with decreasing term\nmagnitudes, the alternating–series estimate gives  \n\\[\n\\lvert R_{N+1}\\rvert<\\frac{1}{(N+2)!},\n\\qquad\n\\operatorname{sgn}\\bigl(R_{N+1}\\bigr)=(-1)^{N+1}.\n\\]\nHence\n\\[\nw(N)=(N+1)E_{N+1}\n      =(N+1)e^{-1}-(N+1)R_{N+1},\n\\]\nand therefore\n\\[\n\\frac{w(N)}{N}\n      =\\frac{1}{e}+\\frac{1}{eN}-\\frac{N+1}{N}R_{N+1}\n      =\\frac{1}{e}+\\frac{1}{eN}+O\\!\\Bigl(\\tfrac{1}{(N+1)!}\\Bigr).\n\\]\nMultiplying the displayed estimate by $N$ yields\n\\[\nw(N)=\\frac{N}{e}+\\frac{1}{e}+O\\!\\Bigl(\\tfrac{1}{(N+1)!}\\Bigr).\n\\]\nBoth limits demanded in part (c) follow immediately.\n\n\\textbf{Step 6.  Why the answer is independent of $p$.}  \nOnly Step 1 involved the parameter $p$, and it disappeared at once in\nthe derivation of the recurrence.  Consequently \\emph{all} further conclusions\n— closed formula, limit, and refined asymptotics — are independent of the\nchoice of $p$.\n\n\\[\n\\square\n\\]",
      "metadata": {
        "replaced_from": "harder_variant",
        "replacement_date": "2025-07-14T19:09:31.870008",
        "was_fixed": false,
        "difficulty_analysis": "1. Higher-dimensional state space  \n   • The parameter k introduces an arbitrary interaction range\n     (blocks of length k instead of 2), multiplying the number of legal\n     local configurations and enlarging the underlying Markov state space\n     exponentially.\n\n2. Additional randomness  \n   • An arbitrary probability vector (p₁,…,p_k) governs which square inside\n     a length-k block is painted; the earlier problems had either a fixed\n     symmetric choice (k=2, p=(½,½)) or a single prescribed number p=⅓.\n     The enhanced variant must work for **all** k and **all** p.\n\n3. More sophisticated machinery  \n   • The solution uses the *Poissonisation trick*, the\n     *empty-interval method*, a *functional generating function*, and the\n     *method of characteristics* for first-order PDEs—techniques that go\n     well beyond the short recurrences and elementary induction that solved\n     the original problem.\n\n4. Deeper theoretical content  \n   • A priori it is far from obvious that the terminal white density should\n     be independent of both k and p.\n     Proving this universality requires viewing the process on the infinite\n     line and solving an *infinite* system of coupled ODEs exactly.\n\n5. Longer logical chain  \n   • Continuous-time reformulation → empty-interval hierarchy →\n     generating-function PDE → characteristic curves → site-density formula →\n     back to finite-N asymptotics → limit, a chain of six conceptual steps\n     (the original solution needed essentially two).\n\nFor all these reasons the enhanced kernel variant is substantially more\ndemanding than both the original AMC problem and the intermediate kernel\nvariant."
      }
    },
    "original_kernel_variant": {
      "question": "Let $p$ be a fixed real number with $0<p<1$ and set $q:=1-p$.  \nFor every non–negative integer $N$ place $N+4$ unit squares in one row and colour the four\n“sentinel’’ squares  \n\\[\n1,\\;2,\\;N+3,\\;N+4\n\\]\nblack, leaving the $N$ squares $3,4,\\dots ,N+2$ white.\n\nRepeatedly perform the following random experiment until no two adjacent squares are\nsimultaneously white.\n\n(1) From all \\emph{ordered} adjacent white pairs $(x,x+1)$ choose one uniformly at random.  \n\n(2) Having chosen $(x,x+1)$, colour $x$ black with probability $p$ and\n$x+1$ black with probability $q$.\n\nLet $w(N)$ be the expected number of white squares that remain when the procedure stops\n(conventions: $w(0)=0$, $w(1)=1$ because for $N=0,1$ no move is possible).\n\n(a)  Show that for $N\\ge 2$\n\\[\nw(N)=w(N-1)+\\frac{w(N-2)}{N-1}.\n\\tag{R}\n\\]\n\n(b)  Prove the closed formula\n\\[\nw(N)=(N+1)\\sum_{k=0}^{N+1}\\frac{(-1)^k}{k!}\\qquad(N\\ge 0).\n\\tag{F}\n\\]\n\n(c)  Deduce the complete first–order asymptotics\n\\[\n\\frac{w(N)}{N}= \\frac{1}{e}+\\frac{1}{eN}+O\\!\\Bigl(\\tfrac{1}{(N+1)!}\\Bigr)\n\\qquad(N\\to\\infty),\n\\]\nand in particular\n\\[\n\\lim_{N\\to\\infty}\\frac{w(N)}{N}=\\frac{1}{e},\\qquad\n\\lim_{N\\to\\infty}\\!\\Bigl(w(N)-\\tfrac{N}{e}\\Bigr)=\\frac{1}{e}.\n\\]\n\nYour answers must be independent of $p$.",
      "solution": "Throughout we abbreviate $q:=1-p$ and write  \n\\[\nS(N):=\\sum_{j=0}^{N} w(j)\\qquad(N\\ge 0).\n\\]\n\n\\textbf{Step 1.  Probabilities for the first square that turns black.}  \nRelabel the $N$ initially white squares as $1,2,\\dots ,N$; square $1$ is the\nformer square $3$, etc.  The $(N-1)$ ordered adjacent white pairs are\n\\[\n(1,2),\\,(2,3),\\dots ,(N-1,N).\n\\]\nIf pair $(i,i+1)$ is chosen, square $i$ becomes black with probability $p$\nand $i+1$ with probability $q$.  Hence  \n\\[\n\\Pr(\\text{first black square}=1)=\\frac{p}{N-1},\\qquad\n\\Pr(\\text{first black square}=N)=\\frac{q}{N-1},\n\\]\nand for $2\\le i\\le N-1$\n\\[\n\\Pr(\\text{first black square}=i)=\\frac{1}{N-1}.\n\\tag{1}\n\\]\n\n\\textbf{Step 2.  Splitting after the first colouring.}  \nIf $i$ is the first square to be coloured black, the configuration decomposes\ninto\n\\[\n\\underbrace{\\boxed{\\phantom{\\small 1}}\\dots\\boxed{\\phantom{\\small 1}}}_{i-1\n  \\text{ white squares}}\\qquad\\text{and}\\qquad\n\\underbrace{\\boxed{\\phantom{\\small 1}}\\dots\\boxed{\\phantom{\\small 1}}}_{N-i\n  \\text{ white squares}},\n\\]\neach bracketed by black sentinels at both ends.  \nBy \\emph{additivity of expectation} (independence is not required) the expected\nfinal number of white squares equals the sum of the expectations for the two\nsubsystems.  Therefore\n\\[\nw(N)=\\sum_{i=1}^{N} \\Pr(\\text{first}=i)\\,\n      \\bigl(w(i-1)+w(N-i)\\bigr).\n\\tag{2}\n\\]\n\n\\textbf{Step 3.  A $p$–free recurrence.}  \nInsert (1) into (2).  The two extreme squares occur only once,\nall interior squares twice.  One finds\n\\[\n(N-1)w(N)=w(N-1)+2\\sum_{j=1}^{N-2}w(j)=w(N-1)+2S(N-2),\n\\]\nhence\n\\[\nw(N)-w(N-1)=\\frac{w(N-2)}{N-1}\\qquad(N\\ge 2),\n\\]\nwhich is exactly the required recurrence (R).  Observe that the parameter $p$\nhas disappeared completely.\n\n\\textbf{Step 4.  Solving the recurrence.}  \n\\emph{Claim:} formula (F) holds for every $N\\ge 0$.  \n\n\\emph{Proof by induction.}  \nBase cases $N=0,1$ are immediate: $w(0)=0$ and $w(1)=1$ match (F).\nAssume $w(N-1)=f_{N-1}$ and $w(N-2)=f_{N-2}$ with\n\\[\nf_{m}:=(m+1)\\sum_{k=0}^{m+1}\\frac{(-1)^k}{k!}\\quad(m\\ge 0).\n\\]\nUsing (R) it suffices to verify\n\\[\nf_{N}-f_{N-1}=\\frac{f_{N-2}}{\\,N-1}.\n\\tag{3}\n\\]\nCompute\n\\[\n\\begin{aligned}\nf_{N}-f_{N-1}\n&=(N+1)\\sum_{k=0}^{N+1}\\frac{(-1)^k}{k!}\n   -N\\sum_{k=0}^{N}\\frac{(-1)^k}{k!}\\\\\n&=\\sum_{k=0}^{N-1}\\frac{(-1)^k}{k!},\n\\end{aligned}\n\\]\nwhile\n\\[\n\\frac{f_{N-2}}{N-1}\n   =\\sum_{k=0}^{N-1}\\frac{(-1)^k}{k!}.\n\\]\nEquality (3) holds, completing the induction and proving (F).\n\n\\textbf{Step 5.  Precise asymptotics.}  \nWrite $E_{N}:=\\displaystyle\\sum_{k=0}^{N}\\frac{(-1)^k}{k!}$ and \n\\[\nR_{N+1}:=e^{-1}-E_{N+1}\\qquad(N\\ge 0).\n\\]\nBecause the exponential series is alternating with decreasing term\nmagnitudes, the alternating–series estimate gives  \n\\[\n\\lvert R_{N+1}\\rvert<\\frac{1}{(N+2)!},\n\\qquad\n\\operatorname{sgn}\\bigl(R_{N+1}\\bigr)=(-1)^{N+1}.\n\\]\nHence\n\\[\nw(N)=(N+1)E_{N+1}\n      =(N+1)e^{-1}-(N+1)R_{N+1},\n\\]\nand therefore\n\\[\n\\frac{w(N)}{N}\n      =\\frac{1}{e}+\\frac{1}{eN}-\\frac{N+1}{N}R_{N+1}\n      =\\frac{1}{e}+\\frac{1}{eN}+O\\!\\Bigl(\\tfrac{1}{(N+1)!}\\Bigr).\n\\]\nMultiplying the displayed estimate by $N$ yields\n\\[\nw(N)=\\frac{N}{e}+\\frac{1}{e}+O\\!\\Bigl(\\tfrac{1}{(N+1)!}\\Bigr).\n\\]\nBoth limits demanded in part (c) follow immediately.\n\n\\textbf{Step 6.  Why the answer is independent of $p$.}  \nOnly Step 1 involved the parameter $p$, and it disappeared at once in\nthe derivation of the recurrence.  Consequently \\emph{all} further conclusions\n— closed formula, limit, and refined asymptotics — are independent of the\nchoice of $p$.\n\n\\[\n\\square\n\\]",
      "metadata": {
        "replaced_from": "harder_variant",
        "replacement_date": "2025-07-14T01:37:45.659299",
        "was_fixed": false,
        "difficulty_analysis": "1. Higher-dimensional state space  \n   • The parameter k introduces an arbitrary interaction range\n     (blocks of length k instead of 2), multiplying the number of legal\n     local configurations and enlarging the underlying Markov state space\n     exponentially.\n\n2. Additional randomness  \n   • An arbitrary probability vector (p₁,…,p_k) governs which square inside\n     a length-k block is painted; the earlier problems had either a fixed\n     symmetric choice (k=2, p=(½,½)) or a single prescribed number p=⅓.\n     The enhanced variant must work for **all** k and **all** p.\n\n3. More sophisticated machinery  \n   • The solution uses the *Poissonisation trick*, the\n     *empty-interval method*, a *functional generating function*, and the\n     *method of characteristics* for first-order PDEs—techniques that go\n     well beyond the short recurrences and elementary induction that solved\n     the original problem.\n\n4. Deeper theoretical content  \n   • A priori it is far from obvious that the terminal white density should\n     be independent of both k and p.\n     Proving this universality requires viewing the process on the infinite\n     line and solving an *infinite* system of coupled ODEs exactly.\n\n5. Longer logical chain  \n   • Continuous-time reformulation → empty-interval hierarchy →\n     generating-function PDE → characteristic curves → site-density formula →\n     back to finite-N asymptotics → limit, a chain of six conceptual steps\n     (the original solution needed essentially two).\n\nFor all these reasons the enhanced kernel variant is substantially more\ndemanding than both the original AMC problem and the intermediate kernel\nvariant."
      }
    }
  },
  "checked": true,
  "problem_type": "calculation"
}