login
This site is supported by donations to The OEIS Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A274369 Let the starting square of Langton's ant have coordinates (0, 0), with the ant looking in negative x-direction. a(n) is the x-coordinate of the ant after n moves. 4
0, 0, 1, 1, 0, 0, -1, -1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 2, 2, 1, 1, 2, 2, 3, 3, 2, 2, 1, 1, 2, 2, 3, 3, 4, 4, 3, 3, 2, 2, 3, 3, 2, 2, 3, 3, 2, 2, 1, 1, 0, 0, -1, -1, 0, 0, -1, -1, 0, 0, -1, -1, -2, -2, -1, -1, -2, -2, -3, -3, -2, -2, -1, -1, -2, -2, -3 (list; graph; refs; listen; history; text; internal format)
OFFSET

0,21

LINKS

Rémy Sigrist, Table of n, a(n) for n = 0..15000

Felix Fröhlich, Coordinates of Langton's ant.

Wikipedia, Langton's ant.

FORMULA

a(n+104) = a(n) + 2 for n > 9975. - Andrey Zabolotskiy, Jul 05 2016

PROG

(Python)

# A274369: Langton's ant by Andrey Zabolotskiy, Jul 05 2016

def ant(n):

....steps = [(1, 0), (0, 1), (-1, 0), (0, -1)]

....black = set()

....x = y = 0

....position = [(x, y)]

....direction = 2

....for _ in range(n):

........if (x, y) in black:

............black.remove((x, y))

............direction += 1

........else:

............black.add((x, y))

............direction -= 1

........(dx, dy) = steps[direction%4]

........x += dx

........y += dy

........position.append((x, y))

....return position

print ([p[0] for p in ant(100)])

# change p[0] to p[1] to get y-coordinates

CROSSREFS

Cf. A274370 (y-coordinate).

Cf. A102358, A102369, A204810, A255938, A261990, A269757.

Sequence in context: A112399 A165123 A106180 * A055091 A014678 A164516

Adjacent sequences:  A274366 A274367 A274368 * A274370 A274371 A274372

KEYWORD

sign,look

AUTHOR

Felix Fröhlich, Jun 19 2016

STATUS

approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent | More pages
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy .

Last modified February 23 17:41 EST 2018. Contains 299584 sequences. (Running on oeis4.)