2018-09-30 22:01:58 +00:00
---
id: 5900f4d51000cf542c50ffe8
title: 'Problem 361: Subsequence of Thue-Morse sequence'
2020-11-27 18:02:05 +00:00
challengeType: 5
2019-08-05 16:17:33 +00:00
forumTopicId: 302022
2021-01-13 02:31:00 +00:00
dashedName: problem-361-subsequence-of-thue-morse-sequence
2018-09-30 22:01:58 +00:00
---
2020-11-27 18:02:05 +00:00
# --description--
2018-09-30 22:01:58 +00:00
2021-07-29 19:48:17 +00:00
The Thue-Morse sequence $\\{T_n\\}$ is a binary sequence satisfying:
2018-09-30 22:01:58 +00:00
2021-07-29 19:48:17 +00:00
- $T_0 = 0$
- $T_{2n} = T_n$
- $T_{2n + 1} = 1 - T_n$
2018-09-30 22:01:58 +00:00
2021-07-29 19:48:17 +00:00
The first several terms of $\\{T_n\\}$ are given as follows: $01101001\color{red}{10010}1101001011001101001\ldots$.
2018-09-30 22:01:58 +00:00
2021-07-29 19:48:17 +00:00
We define $\\{A_n\\}$ as the sorted sequence of integers such that the binary expression of each element appears as a subsequence in $\\{T_n\\}$. For example, the decimal number 18 is expressed as 10010 in binary. 10010 appears in $\\{T_n\\}$ ($T_8$ to $T_{12}$), so 18 is an element of $\\{A_n\\}$. The decimal number 14 is expressed as 1110 in binary. 1110 never appears in $\\{T_n\\}$, so 14 is not an element of $\\{A_n\\}$.
2018-09-30 22:01:58 +00:00
2021-07-29 19:48:17 +00:00
The first several terms of $A_n$ are given as follows:
2018-09-30 22:01:58 +00:00
2021-07-29 19:48:17 +00:00
$$\begin{array}{cr}
n & 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12 & \ldots \\\\
A_n & 0 & 1 & 2 & 3 & 4 & 5 & 6 & 9 & 10 & 11 & 12 & 13 & 18 & \ldots
\end{array}$$
2018-09-30 22:01:58 +00:00
2021-07-29 19:48:17 +00:00
We can also verify that $A_{100} = 3251$ and $A_{1000} = 80\\,852\\,364\\,498$.
2018-09-30 22:01:58 +00:00
2021-07-29 19:48:17 +00:00
Find the last 9 digits of $\displaystyle\sum_{k = 1}^{18} A_{{10}^k}$.
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
# --hints--
2018-09-30 22:01:58 +00:00
2021-07-29 19:48:17 +00:00
`subsequenceOfThueMorseSequence()` should return `178476944` .
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
```js
2021-07-29 19:48:17 +00:00
assert.strictEqual(subsequenceOfThueMorseSequence(), 178476944);
2018-09-30 22:01:58 +00:00
```
2020-11-27 18:02:05 +00:00
# --seed--
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
## --seed-contents--
2018-09-30 22:01:58 +00:00
```js
2021-07-29 19:48:17 +00:00
function subsequenceOfThueMorseSequence() {
2020-09-15 16:57:40 +00:00
2018-09-30 22:01:58 +00:00
return true;
}
2021-07-29 19:48:17 +00:00
subsequenceOfThueMorseSequence();
2018-09-30 22:01:58 +00:00
```
2020-11-27 18:02:05 +00:00
# --solutions--
2018-09-30 22:01:58 +00:00
```js
// solution required
```