Mathematical and Physical Journal
for High Schools
Issued by the MATFUND Foundation
Already signed up?
New to KöMaL?

Problem A. 893. (December 2024)

A. 893. In a text editor program, initially there is a footprint symbol (L) that we want to multiply. Unfortunately, our computer has been the victim of a hacker attack, and only two functions are working: Copy and Paste, each costing \(\displaystyle 1\) Dürer dollar to use. Using the Copy function, we can select one or more consecutive symbols from the existing ones, and the computer memorizes their number. When using the Paste function, the computer adds as many new footprint symbols to the sequence as were selected in the last Copy. If no Copy has been done yet, Paste cannot be used. Let \(\displaystyle D(n)\) denote the minimum number of Dürer dollars required to obtain exactly \(\displaystyle n\) footprint symbols. Prove that for any positive integer \(\displaystyle k\), there exists a positive integer \(\displaystyle N\) such that \(\displaystyle D(N)={D(N+1)}+1={D(N+2)}={D(N+3)}+1={D(N+4)}=\ldots ={D(N+2k-1)}+1={D(N+2k)}\).

Based on a problem of the Dürer Competition

(7 pont)

Deadline expired on January 10, 2025.


Let's divide the steps into blocks: a block starts with a Copy and ends just before the next Copy, meaning each block contains exactly one Copy as its first step. First, we show that for any \(\displaystyle n\), it is possible to reach \(\displaystyle n\) footprints with \(\displaystyle D(n)\) steps such that every block has a maximum size of 3.

Assume indirectly that this is not true, and there exists a number \(\displaystyle n\) for which any sequence achieving \(\displaystyle n\) footprints with a cost of \(\displaystyle D(n)\) contains at least one block of size 4 or more. Consider a sequence that produces \(\displaystyle n\) footprints in \(\displaystyle D(n)\) steps, where the longest block has minimal length \(\displaystyle k \geq 4\).

Take a block of length \(\displaystyle k\), consisting of one Copy followed by \(\displaystyle k-1\) Pastes. Instead, perform the Copy as before, but only \(\displaystyle k-3\) Pastes (where \(\displaystyle k-3 \geq 1\)), then Copy twice as many characters as initially copied in the block and Paste once. This uses the same number of steps and results in the same number of footprints but splits the block into two shorter blocks. Applying this to all blocks of length \(\displaystyle k\) reduces the maximum block length, leading to a contradiction. Thus, we conclude that from now on, we can assume every block has at most length 3.

Based on this, we show that \(\displaystyle D(n)\) satisfies the following recursion for \(\displaystyle n \geq 2\).

\(\displaystyle D(n)=\min\left(2+\min_{n/2 \leq k <n} D(k), \ \ 3+\min_{\substack{n/3 \leq k <n \\ 2 \mid n-k}} D(k)\right). \)

This holds because when expressing \(\displaystyle n\) with blocks of at most length 3, the last block is either of length 2 or 3. In the first case, before the last block, we must have at least \(\displaystyle n/2\) footprints, and with two additional steps, we can produce the remaining footprints. In the second case, achieving exactly \(\displaystyle n\) footprints with a block of length 3 requires at least \(\displaystyle k \geq n/3\) footprints beforehand and that \(\displaystyle 2 \mid n-k\) to be able to reach exactly \(\displaystyle n\) footprints with Pasting the same number of footprints twice.

By examining small cases, we can conjecture the general formula for \(\displaystyle D(n)\), valid for \(\displaystyle n \geq 4\). Let \(\displaystyle k\) be the unique positive integer such that \(\displaystyle 3^k + 1 \leq n \leq 3^{k+1}\). We further partition this interval:

It is evident that in the last case, \(\displaystyle 3k + 3\) and \(\displaystyle 3k + 4\) alternate. Hence proving this formula for \(\displaystyle D(n)\) would complete the solution.

Using the recursive formula, proving the formula by induction on \(\displaystyle k\) is straightforward. For the base case, we verify \(\displaystyle D(1) = 0\), \(\displaystyle D(2) = 2\), \(\displaystyle D(3) = 3\), \(\displaystyle D(4) = 4\), \(\displaystyle D(5) = D(6) = 5\), \(\displaystyle D(7) = D(8) = D(9) = 6\), confirming the statement for \(\displaystyle k=1\), i.e., when \(\displaystyle 3^1 + 1 \leq n \leq 3^2\).

Now assume the formula holds for all \(\displaystyle n \leq 3^k\) and prove it for \(\displaystyle 3^k + 1 \leq n \leq 3^{k+1}\).


Statistics:

15 students sent a solution.
7 points:Aravin Peter, Bodor Mátyás, Czanik Pál, Holló Martin, Keresztély Zsófia, Kocsis 827 Péter, Minh Hoang Tran, Morvai Várkony Albert, Szakács Ábel, Varga Boldizsár, Wágner Márton, Xiaoyi Mo.
5 points:1 student.
0 point:2 students.

Problems in Mathematics of KöMaL, December 2024