Sunday, July 16, 2023

Order of Operations

You are writing an expression using the whole numbers $1, 2, 3, 4, 5, \dots, 4N + 1,$ for some nonnegative integer $N$ and the operations of addition, subtraction, multiplication, and division. Importantly, you must use each number exactly once and each operation exactly $N$ times. Also, you can use as many parentheses as you would like. No concatenation of the digits is allowed (i.e., you can’t combine $2$ and $3$ to make the number $23$). What is the largest value you can generate, using the nine digits and eight operations?

The largest number generated using integers numbers $1, \dots, 4N+1$ and the four operations provided that each operation is used $N$ times is $$m(N) = (4N+1) (6N+1)^N.$$

To prove this we will need to argue first that $m(N)$ is equivalent to the number $\hat{m}(N),$ which is the largest number that can be constructed using only $N$ multiplications and $N$ additions using the number $2N+1, 2N+2, \dots, 4N, 4N+1.$ Certainly, any arithmetic expression using only $N$ multiplications and $N$ additions and the numbers $2N+1, \dots, 4N+1$ each once, say $x = f(2N+1, \dots, 4N+1),$ can be made into an aritchmetic expression using each of the integers $1, \dots, 4N+1$ once and each operation exactly $N$ times, by simply letting $$x = g(1, \dots, 4N+1) = \frac{f(2N+1, \dots, 4N+1)}{ (2N - (2N-1)) \cdot \cdots \cdot (2 - 1) }.$$ Therefore, we must have $m(N) \geq \hat{m}(N).$ We can reasonably hand-wave that it cannot be the case that $m(N) \gt \hat{m}(N),$ since that would imply that the largest possible outcome either consists of dividing by some non-unit divisor or subtracting some integer from a larger arithmetic expression. Both of which yield contradictions.

OK, so we have reasonably almost halved the problem and can now focus on only a problem of $N$ multiplications, $N$ additions and the integers $2N+1, \dots, 4N+1.$ Similar to the hand-wavey arguments above, it is straightforward that $\hat{m}(N)$ has the form $$x_1 \cdot (x_2 + x_3) \cdot \cdots \cdot (x_{2N} + x_{2N+1})$$ for some choice of $x = (x_1, \dots, x_{2N+1}) \in \mathfrak{X}$ where $$\mathfrak{X} := \{ (x_1, \dots, x_{2N+1}) \in \{2N+1, \dots, 4N+1\}^{(2N+1)} \mid x_i \ne x_j, \forall i \ne j \}.$$ With all of that hand-waving done, the only thing that is left to do is decipher the appropriate, maximal assignment of the variables $x = (x_1, \dots, x_{2N+1}) \in \mathfrak{X}.$

The AM-GM inequality states the arithmetic mean of nonnegative numbers is always greater than or equal to the geometric mean of those same numbers, that is, for any positive integer $k$ and any real numbers $y_1, \dots, y_k \geq 0,$ $$\frac{y_1 + \cdots + y_k}{k} \geq \sqrt[k]{y_1 \cdot \cdots \cdot y_k}.$$ So with the help of said AM-GM inequality, for any choice of variable assignments $x = (x_1, \dots, x_{2N+1}) \in \mathfrak{X},$ \begin{align*} x_1 \cdot (x_2 + x_3) \cdot \cdots \cdot (x_{2N} + x_{2N+1}) &= x_1 \prod_{i=1}^N (x_{2i} + x_{2i+1})\\ &\leq x_1 \left( \frac{ \sum_{i=1}^N (x_{2i} + x_{2i+1}) }{ N } \right)^{N} \\ &= x_1 \left( \frac{ \sum_{i=2}^{2N+1} x_i }{N} \right)^N\\ &= x_1 \left( \frac{(2N+1)(3N+1) - x_1}{N} \right)^N,\end{align*} where the last equality comes from the fact that $\sum_{i=2N+1}^{4N+1} i = (2N+1)(3N+1).$ Since the derivative of the right-hand side of the inequality is positive whenever $x_1 \lt \frac{(2N+1)(3N+1)}{N},$ and $\frac{(2N+1)(3N+1)}{N} \gt 4N+1$ for all nonnegative integers $N,$ if we want to maximize the right-hand side of the inequality for the choice of $x_1 \in \{2N+1, \dots, 4N+1\},$ we obtain the upper bound for \begin{align*}\hat{m}(N) &\leq (4N+1) \left( \frac{(2N+1)(3N+1) - (4N+1)}{N} \right)^N\\ &= (4N+1) \left( \frac{6N^2 + 5N + 1 - (4N+1)}{N} \right)^N\\ &= (4N+1) (6N+1)^N.\end{align*} On the flip side, this upper bound is actually achieved by $\hat{x} \in \mathfrak{X}$ such that \begin{align*} \hat{x}_1 &=4N+1, \\ \hat{x}_2 &= 2N+1,\\ \hat{x}_3 &= 4N, \\ \hat{x}_4 &= 2N+2, \\ \hat{x}_5 &= 4N-1,\\ &\dots, \\ \hat{x}_{2i} &= 2N+i,\\ \hat{x}_{2i+1} &= 4N-i+1,\\ &\dots, \\ \hat{x}_{2N} &= 3N, \\ \hat{x}_{2N+1} &= 3N+1\end{align*} so we have "proven" (via some hand waving) that $$m(N) = \hat{m}(N) = (4N+1) (6N+1)^N.$$ In particular, the first few values of $m(N)$ are given by 35, 1,521, 89,167, 6,640,625, and 601,212,171 for $N= 1, 2, 3, 4,$ and $5,$ respectively. I smell a new OEIS entry coming on ...

Monday, July 10, 2023

New Riddle Service .... Who Dis?

N.B.Given the new iteration of the Riddler, there are those who might surmise that I would change the name of my Riddler answer blog from on of the aliases of the Batman villain to some fiddling pun, like, I'm just spitballing here, I dunno... Stradi's Various Answers Shop, but I am lazy, so Ed Nigma lives on!

Suppose I start with a strip of paper that’s 10 inches long and 1 inch wide. I twist it once and attach the two 1-inch edges together, forming a Möbius strip. Finally, I draw a dot somewhere in the center of the strip—that is, the dot is half an inch away from both edges.

Naturally, the distance between any two points on my strip is the shortest path between them, as the ant crawls. By that, I mean that such paths can go over an edge to the other “side” of the strip (“side” in quotes because it’s all really the same side, after all), just as an ant would crawl around the edge of the paper. There is a unique point on the strip that is the farthest distance from my dot. What is this distance?

We can represent the strip of paper as a $10" \times 1"$ rectangle that has two (2) $10" \times 0.5"$ rectangles stacked immediately above and immediately below it. The two smaller rectangles represent the ``other side'' of the strip. Since this is a M\"{o}bius strip, the orientation of the left and right sides of the rectangles are reversed, so for instance lower left and upper right corners of the 10" \times 1" rectangle are the same point and same with the upper left and lower right. Meanwhile, the upper edge of the upper smaller rectangle and lower edge of the lower smaller rectangle are the same. Additionally, the midpoint of left side of the $10" \times 1"$ rectangle is simultaneous the upper right corner of the upper smaller rectangle and the lower right corner of the lower smaller rectangle, and vice versa with the midpoint of the right side of the larger rectangle. That was confusing enough, so let's set up a frame of reference and see if we can measure something, eh?

Assume the larger rectangle is given by $\{ (x,y) \mid 0 \leq x \leq 10, |y| \leq 0.5 \},$ with the upper and lower smaller rectangles given by $\{ (x,y) \mid 0 \leq x \leq 10, 0.5 \leq \pm y \leq 1 \},$ respectively. Finally, without loss of generality, assume that your mark is made at the origin. Then since the points $(0,0)$, $(10,1)$ and $(10,-1)$ are synonymous, the ``as the ant crawls'' metric is given by $$d(x,y) = \min \{ \sqrt{x^2+y^2}, \sqrt{ (x-10)^2 + (y-1)^2 }, \sqrt{ (x-10)^2 + (y+1)^2 } \}.$$ Maximizing this metric over the set $\{ (x,y) \mid 0 \leq x \leq 10, |y| \leq 1 \}$ gives the maximum possible distance away of $$d^* = \max_{ 0\leq x \leq 10, |y| \leq 1 } d(x,y) = 5.05,$$ which is obtained at the point $(x^*, y^*) = (5.05, 0)$ which is synonymous with the points $(4.95, \pm 1).$

Monday, June 19, 2023

Middle Square Madness

This week, let’s look at the middle-square method for generating pseudorandom four-digit numbers. First, we start with a four-digit number, such as $9,876.$ If we square it, we get the eight-digit number $97,535,376.$ Our next pseudorandom number is taken from the middle four digits of that square: $5,353.$ And to get the next pseudorandom number, we can square $5,353,$ which gives us $28,654,609,$ the middle four digits of which are $6,546.$

Of course, many four-digit numbers have a square that’s seven digits rather than eight. And in a sequence of middle-square numbers, you also might encounter smaller numbers whose squares have six or fewer digits. In these cases, you can append zeros to the beginning of the square until you have eight total digits, and once again take the middle four digits.

No matter what initial four-digit number you pick, your sequence of pseudorandom numbers will eventually repeat itself in a loop. If you want the longest sequence of such numbers before any repetition occurs, what starting number should you pick? And how many unique numbers are in the sequence?

Mathematically, the middle square pseduorandom operation can be written as the following recurrence $$x_{n+1} = ( x_n \mod 1000000 ) // 100, \, \forall n \geq 1.$$ That is, first take the remainder when dividing by a million then use the integer divisor when dividing by $100.$ The assertion (which makes sense since there are only no more than $100,000$ possible values to take) is that eventually there will be some $n$ such that $$x_{n+1} \in \{ x_1, \dots, x_n \}.$$ This means that for any initial value of $x_1,$ we can generate the sequence of successive iterations of the middle square recurrence, each time checking the stopping criterion above. While there may certainly have been more elegeant techniques, I brute forced my way through to a solution of using $6,239$ as an inital value, which results in sequence of $111$ unique numbers before any repetitions.

Interestingly, though perhaps owing to a benevalent question-crafter more than anything else, there is only one such initial value that yields a sequence of $111$ unique numbers before repetitions, and all other positive integers $n \lt 111$ have at least $3$ initial values that lead to a sequence of $n$ unique values before repetitions. For instance, there are three fixed points of the middle square recurrence, namely $2,500$, $3,792$ and $7,600,$ where each exhibits $$x_2 = (x_1 \mod 1000000) // 100 = x_1.$$ Similarly, there are $3$ initial values that lead to a sequence of $110$ unique values before repetitions, namely $3,416$, $4,655$, and $9,251.$

Sunday, June 18, 2023

Laissez le bon temps rouler, or have a flipping good time!

Starting a competition with the flip of a coin (say, to determine possession of a ball) is so boring! Instead, let’s give the captain of one team a fair coin and the captain of the other team a fair die. The captain with the coin will flip it at the same time the other captain rolls the die. They continue doing this until the coin is the same (whether heads or tails) for three consecutive flips or the number that comes face-up on the die is the same for two consecutive rolls.

On average, how many coin flips will it take to get three in a row? And how many die rolls will it take to get two in a row?

Extra credit: While the numbers of flips and rolls may often be the same, which team — the team with the coin or the team with the die — is more likely to win the toss/roll? (That is, which is more likely to happen sooner?)

Let's tackle the expectation case first. Let's say that $R$ is the randome number of rolls to get two in a row on a fair die and $F$ is the random number of flips to get three in a row. Let's denote the outcome of the $k$th roll as $r_k$ and similarly the outcome of the $k$th flip as $f_k.$

Assume without loss of generality that the roller's first roll is some $i \in \{1, 2, 3, 4, 5, 6\}.$ Then the second roll will either be $i$, with probability $1/6,$ or some $j \ne i,$ with probability $5/6.$ So we have $$\mathbb{E}[R \mid r_1 = i] = \frac{1}{6} \mathbb{E}[ R \mid r_1 = r_2 = i ] + \frac{5}{6} \mathbb{E}[ R \mid r_1 = i \ne j = r_2 ].$$ In the former case, $R \equiv 2$ if $r_1 = r_2 = i$; alternatively, in the latter case, $R \mid r_1 = i \ne j = r_2$ is equivalent to $1 + R \mid r_1 = j.$ Due to the arbitrariness of the choice of initial roll realization, $\mathbb{E} [ R \mid r_1 = i ] = \mathbb{E} [ R \mid r_1 = j ],$ for all $i, j \in \{ 1, 2, 3, 4, 5, 6 \}$ we have $$\mathbb{E}[ R \mid r_1 = i ] = \frac{1}{6} 2 + \frac{5}{6} ( 1 + \mathbb{E} [ R \mid r_1 = i ] )$$ or equivalently, $$\mathbb{E} [ R \mid r_1 = i ] = 7.$$ So therefore, the expected number of rolls is $$\mathbb{E} [ R ] = \sum_{i=1}^6 \frac{1}{6} \mathbb{E} [ R \mid r_1 = i ] = 7,$$ again due to the arbitrariness of the initial roll realization.

Literally and figuratively on the flip side .... Let's assume without loss of generality that the first flip is $H$. The second flip is either again a $H$ or it will be a $T$, each with $1/2$ probability. So by the law of total expectation we have $$\mathbb{E} [F \mid f_1 = H] = \frac{1}{2} \mathbb{E} [ F \mid f_1 = f_2 = H ] + \frac{1}{2} \mathbb{E} [ F \mid f_1 = H, f_2 = T].$$ As before, we see that $\mathbb{E} [F \mid f_1 = H] = \mathbb{E} [F \mid f_1 = T],$ so we have $\mathbb{E} [ F \mid f_1 = H, f_2 = T ] = 1 + \mathbb{E} [ F \mid f_1 = H ].$ Going one step further if $f_1 = f_2 = H,$ then either $f_3 = H$ and we are done (with $F = 3$), or $f_3 = T,$ where we have $$\mathbb{E} [ F \mid f_1 = f_2 = H, f_3 = T ] = 2 + \mathbb{E}[F \mid f_1 = H].$$ So we have $$\mathbb{E} [F \mid f_1 = H] = \frac{1}{2} \left( \frac{1}{2} 3 + \frac{1}{2} (2 + \mathbb{E} [ F \mid f_1 = H ]) \right) + \frac{1}{2} ( 1 + \mathbb{E} [F \mid f_1 = H ] ),$$ or equivalently, $$\mathbb{E}[ F \mid f_1 = H ] = 7.$$ Once again, since the outcome of the choice of first flip was arbitrary, the expected number of flips is $$\mathbb{E}[F] = \frac{1}{2} \mathbb{E}[ F \mid f_1 = H ] + \frac{1}{2} \mathbb{E} [F \mid f_1 = T] = 7,$$ so the expectation is the same number of rolls and flips are the same.

So it is all well and good that the expected number of flips is the same, but will one side or the other be advantaged by the new method for determining the initial possession? Yes, the flipper will end up with a better odds of winning. Here I will give some hand-wavy justifications, but spinning up some simulations will additionally bear this out. The roller will always consistently have a $5/6$ probability of not winning on each roll. However, the flipper has a more volatile distribution not winning: if she just switched from $H$ to $T$ or vice versa, then the probability of not winning on the next roll is $100%,$ but if there are two in a row it drops to an even $50%$ of winning/not-winning. So as long as the flipper doesn't constantly go into streaks of alternating between H and T one after another, the flipper will have a lower probability of not-losing, or conversely probability of winning in the next round.

Sunday, February 12, 2023

The emperor's new integer solutions

Find all pairs of integers $a$ and $b$ that are solutions to the following equation: $$a\cdot(a+1)\cdot(a+2) = b^2+4.$$

That’s it. That’s the riddle.

First, since $a$, $a+1$ and $a+2$ are three consecutive integers, one of them must be divisible by $3,$ so therefore their product $a \cdot (a+1) \cdot (a+2)$ is divisible by three. So regardless of the value of $a \in \mathbb{Z}$, the lefthand side of the equation is divisible by $3$.

Secondly, we can show that the righthand side of the equation cannot be divisible by three. If $3 \mid b,$ say with $b = 3\ell$, then clearly $$b^2+4 = 9 \ell^2 + 4 = 3(3 \ell^2 + 1) + 1 \equiv 1 \!\!\!\!\mod 3,$$ so if $3 \mid b$ then $3\not\mid b^2 + 4.$ On the other hand $3 \not\mid b,$ then Fermat's little theorem states that $$b^2 \equiv 1 \!\!\!\!\mod 3,$$ so for instance, if $3 \not\mid b$ then there is some $m \in \mathbb{Z}$ with $$b^2 = 3m + 1, so b^2 + 4 = 3m + 5 = 3(m+1) + 2 \equiv 2 \!\!\!\!\mod 3.$$ Thus, regardless of the value of $b \in \mathbb{Z}$, the righthand side of the equation is not divisble by $3.$

Therefore, since for any $a \in \mathbb{Z}$ the lefthand side is divisible by $3$, but for any $b \in \mathbb{Z}$ the righthand side cannot be divisible by $3,$ then there are no integer solutions to $$a\cdot(a+1)\cdot(a+2) = b^2 + 4.$$

While Fermat shuts the party down for $\mathbb{Z}^2,$ if we invite Gauss in, there are solutions over the Gaussian integers, e.g., $(-2, \pm 2i),$ $(-1, \pm 2i),$ and $(0, \pm 2i).$ But this might be a bridge too far for this particular riddle.

Saturday, February 4, 2023

How many bottles of beer is it again?

You and your friends are singing the traditional song, “99 Bottles of Beer.” With each verse, you count down the number of bottles. The first verse contains the lyrics “99 bottles of beer,” the second verse contains the lyrics “98 bottles of beer,” and so on. The last verse contains the lyrics “1 bottle of beer.”

There’s just one problem. When completing any given verse, your group of friends has a tendency to forget which verse they’re on. When this happens, you finish the verse you are currently singing and then go back to the beginning of the song (with 99 bottles) on the next verse.

For each verse, suppose you have a 1 percent chance of forgetting which verse you are currently singing. On average, how many total verses will you sing in the song?

Extra credit: Instead of “99 Bottles of Beer,” suppose you and your friends are singing “$N$ Bottles of Beer,” where $N$ is some very, very large number. And suppose your collective probability of forgetting where you are in the song is $1/N$ for each verse. If it takes you an average of $K$ verses to finish the song, what value does the ratio of $K/N$ approach?

Let's define some variables. Let's say that $B_n$ is the number of bottles of beer on the wall in the $n$th verse and let's say that you start with $B_1 = N$ bottles of beer. Then the transition from $B_n$ to $B_{n+1}$ is given by $$B_{n+1} = \begin{cases} B_n - 1, &\text{with probability $1-p$}\\ N, &\text{with probability $p$}\end{cases}$$ which holds even if $B_n = 1.$ That is, the last verse is "1 bottle of beer on the wall, 1 bottle of beer, take 1 down pass it around, no bottles of beer on the wall," but somehow perhaps having ingested a few too many of the bottles of beer, your crew could still end up singing "1 bottle of beer on the wall, 1 bottle of beer, take 1 down pass it around, $N$ bottles of beer on the wall" and you'd have to make your way all the way back down. So in this setup, we need to also state that the transition with $B_{n+1} = 0$ if $B_n = 0,$ $\forall n.$ Finally, let's define the expected number of verses as $V_n = \mathbb{E}\left[ \min \{ k : B_k = 0 \} \mid B_1 = n\right],$ for any $n = 1, \dots, N.$

Now since there are only two possibilities at the end of each verse, we have \begin{align}V_n &= \mathbb{E} \left[ \min \{k : B_k = 0\} \mid B_2 = n-1, B_1 = n \right] \mathbb{P} \{ B_2 = n-1 \mid B_1 = n \}\\ &\quad\quad + \mathbb{E} \left[ \min \{k : B_k=0\} \mid B_2 = N, B_1 = n \right] \mathbb{P} \left\{ B_2 = N \mid B_1 = n \right\} \\ &= (1 + V_{N-1}) (1-p) + (1 + V_N) p\\ &= (1-p) V_{n-1} + pV_N + 1,\end{align} for all $n = 1, \dots, N,$ with $V_0 = 0.$

So in particular, we have $$V_N = (pV_N + 1) + (1-p) V_{N-1}.$$ We can use this as the base case to prove that $$V_N = (pV_N+1) \sum_{i=0}^{k-1} (1-p)^i + (1-p)^k V_{N-k}$$ for all $k = 1, \dots, N.$ In particular, assume that for some $k > 1,$ then substituting in the recurrence relationship for $V_{N-k}$ we get \begin{align*} V_N &= (pV_N+1) \sum_{i=0}^{k-1} (1-p)^i + (1-p)^k ( (1-p) V_{N-k-1} + pV_N + 1) \\ &= (pV_N+1) \sum_{i=0}^k (1-p)^i + (1-p)^{k+1} V_{N-k-1},\end{align*} that is, the formula is also true for $k+1.$ So, by induction, the formula must hold for all $k = 1, \dots, N,$ including for instance $k=N,$ so that \begin{align*}V_N &= (pV_N+1) \sum_{i=0}^{N-1} (1-p)^i + (1-p)^N V_0 = (pV_N+1) \sum_{i=0}^{N-1} (1-p)^i \\ &= (pV_N+1) \frac{1 - (1-p)^N}{p}.\end{align*}

Solving for $V_N$ we get $$V_N = \frac{1 - (1-p)^N}{p(1-p)^N}.$$ So in particular if $N = 99$ and $p = 0.01,$ then we get an average of $$\frac{1-(0.99)^{99}}{0.01 * (0.99)^{99}} \approx 170.467$$ verses. However, if we set $p = 1/N,$ then we get $$K=V_N = N\frac{1-(1-1/N)^N}{(1-1/N)^N},$$ so the fraction $$K/N = \frac{1 - (1-1/N)^N}{(1-1/N)^N} = (1-1/N)^{-N} - 1 \to e-1$$ as $N\to \infty.$

Monday, January 23, 2023

Drone Deliveries

A restaurant at the center of Riddler City is testing an airborne drone delivery service against their existing fleet of scooters. The restaurant is at the center of a large Manhattan-like array of square city blocks, which the scooter must follow.

Both vehicles travel at the same speed, which means drones can make more deliveries per unit time. Assume that (1) Riddler City is circular in shape, as you may recall (2) deliveries are made to random locations throughout the city and (3) the city is much, much larger than its individual blocks.

In a given amount of time, what is the expected ratio between the number of deliveries a drone can make to the number of deliveries a scooter can make?

Given the setup, we can assume that the restaurant is at the origin of a unit circle and that the orders come in randomly at any point in the unit disk, that is, $Z = (x,y)$ with $x^2 + y^2 \leq 1.$ The distance traveled by the drone from the restaurant to the point $Z$ is $\|Z\|_2 = \sqrt{x^2 + y^2}$ while the distance traveled by the scooter is $\|Z\|_1 = |x|+|y|.$ Let's also assume that both the drone and the scooter only make one delivery at a time. Then the expected number of deliveries per unit time is proportional to the inverse of the distance traveled per delivery, the expected ratio of number of deliveries by drone versus scooter is roughly equal to the inverse of the ratios of expected distances traveled, that is, $$k= \frac{\mathbb{E} \|Z\|_1}{\mathbb{E} \|Z\|_2}.$$

In polar coordinates the scooter distance can be rewritten as $\|Z\|_1 = r(|\cos \theta | + |\sin \theta|),$ where the absolute values can be dropped in the first quadrant. So, due to symmetry, the numerator of $k$ is given by $$\mathbb{E} \|Z\|_1 = \frac{4}{\pi} \int_0^{\pi/2} \int_0^1 r (\cos \theta + \sin \theta) r dr\, d\theta = \frac{8}{3\pi}.$$

In polar coordinates, $\|Z\|_2 = r,$ so the denominator of $k$ is $$\mathbb{E}\|Z\|_2 = \frac{1}{\pi} \int_0^{2\pi} \int_0^1 r^2 dr\,d\theta = \frac{2}{3}.$$ So, the drone is expected to make $$k= \frac{\frac{8}{3\pi}}{\frac{2}{3}} = \frac{4}{\pi}$$ times as many deliveries per unit time as the scooter.

Extra credit: In addition to traveling parallel to the city blocks, suppose scooters can also move diagonally from one corner of a block to the opposite corner of the block. Now, what is the new expected ratio between the number of deliveries a drone can make and the number of deliveries a scooter can make?

If the scooters are also allowed to move diagonally across blocks, then the equivalent if we think about having to move from the origin to a point that is say $m$ blocks east and $n$ blocks north of the origin, the fastest delivery route would be to go diagonally northeast for $\min \{m,n\}$ blocks then either proceed the remaining $|m-n|$ blocks due east if $m \lt n$ or due north otherwise. In this case the distance traveled is $(\sqrt{2}-1) \min\{m,n\} + \max\{m,n\}$ blocks. In general, zooming back out to our unit circle representation, the distance traveled to any generic point $Z$ in the unit circle is $$\hat{d}(Z) = (\sqrt{2}-1)\min \{|x|,|y|\} + \max\{|x|,|y|\}.$$ The calculation for the expected ratio of number of deliveries per unit time can still proceed analogously, with $$\hat{k} = \frac{ \mathbb{E} \hat{d}(Z) }{ \mathbb{E} \|Z\|_2} = \frac{3}{2} \mathbb{E} \hat{d}(Z).$$

If we focus on the first quadrant where additionally we have $y\leq x$, then $\hat{d}(Z) = x + (\sqrt{2}-1) y$ or in polar coordinates this would be $$\hat{d}(Z) = r\left( \cos \theta + (\sqrt{2}-1) \sin \theta\right),$$ where $0\leq \theta \leq \frac{\pi}{4}.$ By symmetry, we have $$\mathbb{E} \hat{d} (Z) = \frac{8}{\pi} \int_0^{\pi/4} \int_0^1 r\left( \cos \theta + (\sqrt{2}-1) \sin\theta\right) rdr\,d\theta = \frac{16(\sqrt{2}-1)}{3\pi}.$$ So, if scooters can go diagonally across blocks, then the drone is expected to make only $$\hat{k} = \frac{8(\sqrt{2}-1)}{\pi}$$ times as many deliveries per unit time than as the scooter.