We say that a natural number is called special if all of its digits are non-zero and any two adjacent digits in its decimal representation are consecutive (not necessarily in ascending order).
a) Determine the largest special number $m$ whose sum of digits is equal to $2023$.
b) Determine the smallest special number $n$ whose sum of digits is equal to $2022$.
Obviously, we want to maximize the number of digits. Since the sum of the digits is fixed ($2023$), we want to use as small digits as possible: only using $1$ and $2$ would be optimal if possible.
This means that the largest special number starting with $1$ is $12121\ldots12121$ where the digits alternate between $1$ and $2$ and there are $1349$ digits ($675$ ones and $674$ twos).
However, if we start with $2$, we cannot use all ones and twos, so we must use some threes. It follows that the largest special number starting with $2$ is $21212\ldots21212323$ where the digits alternate between $2$ and $1$ until the last four digits, when it switches to $2$ and $3$. This has $1348$ digits ($674$ twos, $672$ ones, and $2$ threes).
The former of these two numbers is larger, so that is the largest special number whose digits sum to $2023.$ $\square$