2018-09-30 22:01:58 +00:00
---
id: 5900f4ca1000cf542c50ffdc
2018-10-20 18:02:47 +00:00
title: 'Problem 349: Langton''s ant'
2020-11-27 18:02:05 +00:00
challengeType: 5
2019-08-05 16:17:33 +00:00
forumTopicId: 302008
2021-01-13 02:31:00 +00:00
dashedName: problem-349-langtons-ant
2018-09-30 22:01:58 +00:00
---
2020-11-27 18:02:05 +00:00
# --description--
2018-10-08 00:01:53 +00:00
An ant moves on a regular grid of squares that are coloured either black or white.
2020-11-27 18:02:05 +00:00
2018-09-30 22:01:58 +00:00
The ant is always oriented in one of the cardinal directions (left, right, up or down) and moves from square to adjacent square according to the following rules:
2020-11-27 18:02:05 +00:00
\- if it is on a black square, it flips the color of the square to white, rotates 90 degrees counterclockwise and moves forward one square.
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
\- if it is on a white square, it flips the color of the square to black, rotates 90 degrees clockwise and moves forward one square.
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
Starting with a grid that is entirely white, how many squares are black after 1018 moves of the ant?
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
`euler349()` should return 115384615384614940.
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
```js
assert.strictEqual(euler349(), 115384615384614940);
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 euler349() {
2020-09-15 16:57:40 +00:00
2018-09-30 22:01:58 +00:00
return true;
}
euler349();
```
2020-11-27 18:02:05 +00:00
# --solutions--
2018-09-30 22:01:58 +00:00
```js
// solution required
```