Problem: Let $n$ be a positive integer.
A frog starts on the number line at $0$.
Suppose it makes a finite sequence of hops, subject to two conditions:
\begin{itemize}
  \ii The frog visits only points in $\{1, 2, \dots, 2^n-1\}$,
  each at most once.
  \ii The length of each hop is in $\{2^0, 2^1, 2^2, \dots\}$.
  (The hops may be either direction, left or right.)
\end{itemize}
Let $S$ be the sum of the (positive) lengths of all hops in the sequence.
What is the maximum possible value of $S$?

Solution: We claim the answer is $\frac{4^n - 1}{3}$.

We first prove the bound.
First notice that the hop sizes
are in $\{2^0, 2^1, \dots, 2^{n - 1}\}$,
since the frog must stay within bounds the whole time.
Let $a_i$ be the number of hops of size $2^i$ the frog makes, for $0\le i\le n - 1$.
\begin{claim*}
  For any $k = 1, \dots, n$ we have
  \[ a_{n-1} + \dots + a_{n-k} \le 2^n - 2^{n-k}. \]
\end{claim*}
\begin{proof}
  Let $m = n-k$ and look modulo $2^m$.
  Call a jump \emph{small} if its length is at most $2^{m-1}$,
  and \emph{large} if it is at least $2^m$;
  the former changes the residue class of the frog modulo $2^m$
  while the latter does not.

  Within each fixed residue modulo $2^m$,
  the frog can make at most $\frac{2^n}{2^m} - 1$ large jumps.
  So the total number of large jumps is at most
  $2^m \left( \frac{2^n}{2^m} - 1 \right) = 2^n - 2^m$.
\end{proof}
(As an example, when $n = 3$ this means there are at most
four hops of length $4$,
at most six hops of length $2$ or $4$,
and at most seven hops total.
Of course, if we want to max the length of the hops,
we see that we want $a_2 = 4$, $a_1 = 2$, $a_0 = 1$,
and in general equality is achieved when $a_m = 2^m$ for any $m$.)

Now, the total distance the frog travels is
\[ S = a_0 + 2a_1 + 4a_2 + \dots + 2^{n-1} a_{n-1}. \]
We rewrite using the so-called ``summation by parts'':
\begin{alignat*}{7}
  S &{}={}& a_0 &{}+{}& a_1 &{}+{}& a_2 &{}+{}& a_3 &{}+{}& \dots &{}+{}& a_{n-1} \\
  &{}+{}& && a_1 &{}+{}& a_2 &{}+{}& a_3 &{}+{}& \dots &{}+{}& a_{n-1} \\
  &{}+{}& && && 2a_2 &{}+{}& 2a_3 &{}+{}& \dots &{}+{}& 2a_{n-1} \\
  &{}+{}& && && && 4a_3 &{}+{}& \dots &{}+{}& 4a_{n-1} \\
  &\vdotswithin+& && && && && \ddots && \vdotswithin{a_{n-1}} \\
  &{}+{}& && && && && && 2^{n-2}a_{n-1}. \\
\end{alignat*}
Hence
\begin{align*}
  S &\le (2^n-2^0) + (2^n-2^1) + 2(2^n-2^2) + \dots + 2^{n-2}(2^n-2^{n-1}) \\
  &= \frac{4^n-1}{3}.
\end{align*}

It remains to show that equality can hold.
There are many such constructions but most are inductive.
Here is one approach.
We will construct two family of paths such that
there are $2^k$ hops of size $2^k$, for every $0\le k\le n - 1$,
and we visit each of $\{0, \dots, 2^n - 1\}$ once,
starting on $0$ and ending on $x$,
for the two values $x\in\{1, 2^n - 1\}$.

The base case $n = 1$ is clear.
To take a path from $0$ to $2^{n+1}-1$.
\begin{itemize}
  \ii Take a path on $\{0, 2, 4, \dots, 2^{n+1} - 2\}$
  starting from $0$ and ending on $2$ (by inductive hypothesis).
  \ii Take a path on $\{1, 3, 5, \dots, 2^{n+1} - 1\}$
  starting from $1$ and ending on $2^{n+1}-1$ (by inductive hypothesis).
  \ii Link them together by adding a single jump $2 \to 1$.
\end{itemize}
The other case is similar, but we route $0 \to (2^{n+1}-2) \to (2^{n+1}-1) \to 1$ instead.
(This can also be visualized as hopping along a hypercube of binary strings;
each inductive step takes two copies of the hypercube
and links them together by a single edge.)

\begin{remark*}
  [Ashwin Sah]
  The problem can also be altered to ask for the minimum value of the sum of the reciprocals of the hop sizes, where further we stipulate that the frog must hit every point precisely once (to avoid triviality). With a nearly identical proof that also exploits the added condition $a_0 + \dotsb + a_{n - 1} = 2^n - 1$, the answer is $n$. This yields a nicer form for the generalization. The natural generalization changes the above problem by replacing $2^k$ with $a_k$ where $a_k \mid a_{k + 1}$, so that the interval covered by hops is of size $a_n$ and the hop sizes are restricted to the $a_i$, where $a_0 = 1$. In this case, similar bounding yields
\[\sum_{i = 1}^{2^n - 1}\frac{1}{b_k}\ge\sum_{i = 0}^{n - 1}\left(\frac{a_{k + 1}}{a_k} - 1\right).\]
Bounds for the total distance traveled happen in the same way as the solution above, and equality for both can be constructed in an analogous fashion.
\end{remark*}