Average of near-diagonal numbers

Consider all 1010-digit numbers d9d8d1d0\overline{d_9 d_8 \cdots d_1 d_0} (so d90d_9 \ne 0) whose digits satisfy dii1|d_i - i| \le 1 for every position i{0,1,,9}i \in \{0, 1, \dots, 9\}. What is the average of all such numbers?

Show hints (2)+
  1. The constraint is per-position, so valid numbers form a product set - average each digit independently, weighted by 10i10^i.
  2. Interior digits average to ii; the boundaries clip to dˉ0=0.5\bar d_0 = 0.5 and dˉ9=8.5\bar d_9 = 8.5.

Answer

Reveal answer →

9376543210.5

Want the full step-by-step worked solution? It's part of Premium - along with a worked solution for every question in the bank.

Asked at: Jane Street, Two Sigma

Related questions