2018-09-30 22:01:58 +00:00
---
id: 5900f5101000cf542c510022
title: 'Problem 419: Look and say sequence'
2020-11-27 18:02:05 +00:00
challengeType: 5
2019-08-05 16:17:33 +00:00
forumTopicId: 302088
2021-01-13 02:31:00 +00:00
dashedName: problem-419-look-and-say-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
The look and say sequence goes 1, 11, 21, 1211, 111221, 312211, 13112221, 1113213211, ...
2020-11-27 18:02:05 +00:00
2018-09-30 22:01:58 +00:00
The sequence starts with 1 and all other members are obtained by describing the previous member in terms of consecutive digits.
2020-11-27 18:02:05 +00:00
2018-09-30 22:01:58 +00:00
It helps to do this out loud:
2020-11-27 18:02:05 +00:00
2018-09-30 22:01:58 +00:00
1 is 'one one' → 11
2020-11-27 18:02:05 +00:00
2018-09-30 22:01:58 +00:00
11 is 'two ones' → 21
2020-11-27 18:02:05 +00:00
21 is 'one two and one one' → 1211
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
1211 is 'one one, one two and two ones' → 111221
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
111221 is 'three ones, two twos and one one' → 312211
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
...
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
Define A(n), B(n) and C(n) as the number of ones, twos and threes in the n'th element of the sequence respectively. One can verify that A(40) = 31254, B(40) = 20259 and C(40) = 11625.
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
Find A(n), B(n) and C(n) for n = 1012. Give your answer modulo 230 and separate your values for A, B and C by a comma. E.g. for n = 40 the answer would be 31254,20259,11625
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
2020-11-27 18:02:05 +00:00
`euler419()` should return 998567458, 1046245404, 43363922.
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
```js
assert.strictEqual(euler419(), 998567458, 1046245404, 43363922);
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
function euler419() {
2020-09-15 16:57:40 +00:00
2018-09-30 22:01:58 +00:00
return true;
}
euler419();
```
2020-11-27 18:02:05 +00:00
# --solutions--
2018-09-30 22:01:58 +00:00
```js
// solution required
```