# Squirrels digging holes

A large colony of squirrels dug holes during the summer and in each hole, they put between 1 and 100 nuts (each quantity has the same probability).

If each squirrel has to eat 100 nuts during the winter, how many holes must he find (in average)?

Each hole contains 50.5 nuts in average, so 2 should be enough, right?

Hint:

Ybbx sbe n pbairetrag frevrf. (Decode with http://www.rot13.com/)

(I appreciate it because it looks so simple but it is damned hard. If you like it, do not forget the up arrow. I often find help in Python and I wish to have enough points so my thanks are not only recorded but displayed, too. I will not get points by helping others, FORTRAN and dBaseIII are not very fashionable anymore and my C strongly stinks FORTRAN.)

• Welcome to Puzzling.SE! For hinting on your puzzle, use "spoilers." This is done by adding >! to the beginning of the line you wish to hide. See here for more markdown help Mar 28, 2018 at 13:00
• In the future, wait a bit to post a hint because a lot of times people like to try and think it through first :) Mar 28, 2018 at 13:02
• @Chowsen - did not read markdown help carefully enough, looked for color. Anyway, I do not mind, rot13 is not wide used anymore and I believe someone might be glad to discover it this way. Mar 28, 2018 at 13:12
• @Oray I agree it requires statistics. Before posting, I browsed the forum, there are puzzles of this kind. Mar 28, 2018 at 13:14
• @puzzledPig If you get to a certain value on one site, you gain the association bonus of 100 extra rep because you're trusted not to be a spammer / bad user. Mar 28, 2018 at 16:44

$(\frac{101}{100})^{99} \approx 2.67803349448$

Why is that?

We procede by induction,
If we want 1 nut, we can dig only 1 hole. Let's say we need to dig $u_n$ hole on average to get $n$ nuts.
When we want $n+1$ nuts, we can decompose the probability as follow, depending on how many nuts we get in the first hole we dig: $u_{n+1}=1*\frac{101-(n+1)}{100}+\sum_{i=1}^n (1+u_i)*\frac{1}{100}$. The first term is if we dig more than enough, and the sum is for each case where we dug up $i$ nuts, which happens with probability $\frac{1}{100}$.
We can simplify this relation as $u_{n+1} = 1 + \sum_{i=1}^n u_i*\frac{1}{100}=u_n+u_n*\frac{1}{100}$ by splitting the last element of the sum and using the induction. Then we have a simple geometric sequence with ratio $\frac{101}{100}$ and starting term $1$, which gives $u_n=(\frac{101}{100})^{n-1}$.

• I did not expect the solution so quickly. Note that if the number of nuts -> inf, the number of holes -> e. Mar 28, 2018 at 13:21

Imagine that whenever you amass exactly $k$ nuts, you receive a stamp labeled $k$, for each $1\le k\le 99$. The time it takes to amass at least 100 nuts is equal to the number of stamps you collect, plus one. By linearity of expectation, the expected time to get 100 nuts is equal to $1+p_1+\dots+p_{99}$, where $p_n$ is the probability of collecting stamp number $n$.

To compute $p_n$, let's count the number of ways to "walk" from 0 to $n$ in $k$ steps. We can choose the $k-1$ intermediate numbers to walk across in $\binom{n-1}{k-1}$ ways. As long as we restrict our attention to $n\le 99$, each of these choices results in a valid walk (all steps are at most $100$). The probability of any walk with $k$ steps is $\frac{1}{100^k}$, so $$p_n=\sum_{k=1}^n \binom{n-1}{k-1}\frac{1}{100^k} = \frac{1}{100}\left(1+\frac{1}{100}\right)^{n-1},$$ using the binomial theorem. This means $p_1,\dots,p_n$ is a geometric progression, so its total can be easily computed easily. The final result is

$$1+p_1+\dots+p_{99} = 1 + \frac{1}{100}\left(\frac{(1+\frac1{100})^{99}-1}{(1+\frac1{100})-1}\right) = \left(\frac{101}{100}\right)^{99}$$
{"ft_lang_label":"__label__en","ft_lang_prob":0.965406,"math_prob":0.9982658,"size":745,"snap":"2023-40-2023-50","text_gpt3_token_len":182,"char_repetition_ratio":0.08367071,"word_repetition_ratio":0.0,"special_character_ratio":0.24026845,"punctuation_ratio":0.125,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99959797,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-12-03T05:27:17Z\",\"WARC-Record-ID\":\"<urn:uuid:019e7af5-d04d-4219-9929-424cbbf7fa82>\",\"Content-Length\":\"171198\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:dcc8b941-44ad-4722-8933-39ad8c614da5>\",\"WARC-Concurrent-To\":\"<urn:uuid:bf5158cc-f712-45b2-824f-863227bfb09d>\",\"WARC-IP-Address\":\"172.64.144.30\",\"WARC-Target-URI\":\"https://puzzling.stackexchange.com/questions/62851/squirrels-digging-holes/62852\",\"WARC-Payload-Digest\":\"sha1:H4FDYR3JAN6LEUITL3Q5D7GO4YBA7MDS\",\"WARC-Block-Digest\":\"sha1:BXHPQ7ZFZR7EHFPT6XJLHXEGY5V4DN6T\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-50/CC-MAIN-2023-50_segments_1700679100484.76_warc_CC-MAIN-20231203030948-20231203060948-00297.warc.gz\"}"}