2018-09-30 23:01:58 +01:00
---
id: 5900f4d91000cf542c50ffea
title: 'Problem 364: Comfortable distance'
2020-11-27 19:02:05 +01:00
challengeType: 5
2019-08-05 09:17:33 -07:00
forumTopicId: 302025
2021-01-13 03:31:00 +01:00
dashedName: problem-364-comfortable-distance
2018-09-30 23:01:58 +01:00
---
2020-11-27 19:02:05 +01:00
# --description--
2021-07-29 21:48:17 +02:00
There are $N$ seats in a row. $N$ people come after each other to fill the seats according to the following rules:
2020-11-27 19:02:05 +01:00
2021-07-29 21:48:17 +02:00
1. If there is any seat whose adjacent seat(s) are not occupied take such a seat.
2. If there is no such seat and there is any seat for which only one adjacent seat is occupied take such a seat.
3. Otherwise take one of the remaining available seats.
2020-11-27 19:02:05 +01:00
2021-07-29 21:48:17 +02:00
Let $T(N)$ be the number of possibilities that $N$ seats are occupied by $N$ people with the given rules. The following figure shows $T(4) = 8$.
2020-11-27 19:02:05 +01:00
2021-07-29 21:48:17 +02:00
< img class = "img-responsive center-block" alt = "eight ways for N seats to be occupied by N people" src = "https://cdn.freecodecamp.org/curriculum/project-euler/comfortable-distance.gif" style = "background-color: white; padding: 10px;" >
2018-09-30 23:01:58 +01:00
2021-07-29 21:48:17 +02:00
We can verify that $T(10) = 61\\,632$ and $T(1\\,000)\bmod 100\\,000\\,007 = 47\\,255\\,094$.
2018-09-30 23:01:58 +01:00
2021-07-29 21:48:17 +02:00
Find $T(1\\,000\\,000)\bmod 100\\,000\\,007$.
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
# --hints--
2018-09-30 23:01:58 +01:00
2021-07-29 21:48:17 +02:00
`comfortableDistance()` should return `44855254` .
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
```js
2021-07-29 21:48:17 +02:00
assert.strictEqual(comfortableDistance(), 44855254);
2018-09-30 23:01:58 +01:00
```
2020-11-27 19:02:05 +01:00
# --seed--
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
## --seed-contents--
2018-09-30 23:01:58 +01:00
```js
2021-07-29 21:48:17 +02:00
function comfortableDistance() {
2020-09-15 09:57:40 -07:00
2018-09-30 23:01:58 +01:00
return true;
}
2021-07-29 21:48:17 +02:00
comfortableDistance();
2018-09-30 23:01:58 +01:00
```
2020-11-27 19:02:05 +01:00
# --solutions--
2018-09-30 23:01:58 +01:00
```js
// solution required
```