2018-09-30 22:01:58 +00:00
---
id: 5900f4291000cf542c50ff3c
title: 'Problem 189: Tri-colouring a triangular grid'
2020-11-27 18:02:05 +00:00
challengeType: 5
2019-08-05 16:17:33 +00:00
forumTopicId: 301825
2021-01-13 02:31:00 +00:00
dashedName: problem-189-tri-colouring-a-triangular-grid
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
2020-11-27 18:02:05 +00:00
Consider the following configuration of 64 triangles:
2018-09-30 22:01:58 +00:00
2021-07-15 13:52:14 +00:00
< img class = "img-responsive center-block" alt = "64 triangles arranged to create larger triangle with side length of 8 triangles" src = "https://cdn.freecodecamp.org/curriculum/project-euler/tri-colouring-a-triangular-grid-1.gif" style = "background-color: white; padding: 10px;" >
2020-11-27 18:02:05 +00:00
We wish to colour the interior of each triangle with one of three colours: red, green or blue, so that no two neighbouring triangles have the same colour. Such a colouring shall be called valid. Here, two triangles are said to be neighbouring if they share an edge. Note: if they only share a vertex, then they are not neighbours.
2018-09-30 22:01:58 +00:00
For example, here is a valid colouring of the above grid:
2021-07-15 13:52:14 +00:00
< img class = "img-responsive center-block" alt = "colored grid of 64 triangles" src = "https://cdn.freecodecamp.org/curriculum/project-euler/tri-colouring-a-triangular-grid-2.gif" style = "background-color: white; padding: 10px;" >
2018-09-30 22:01:58 +00:00
A colouring C' which is obtained from a colouring C by rotation or reflection is considered distinct from C unless the two are identical.
How many distinct valid colourings are there for the above configuration?
2020-11-27 18:02:05 +00:00
# --hints--
2018-09-30 22:01:58 +00:00
2021-07-15 13:52:14 +00:00
`triangularGridColoring()` should return `10834893628237824` .
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
```js
2021-07-15 13:52:14 +00:00
assert.strictEqual(triangularGridColoring(), 10834893628237824);
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-15 13:52:14 +00:00
function triangularGridColoring() {
2020-09-15 16:57:40 +00:00
2018-09-30 22:01:58 +00:00
return true;
}
2021-07-15 13:52:14 +00:00
triangularGridColoring();
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
```