cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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.

This page as a plain text file.
%I A274369 #27 May 15 2021 05:45:20
%S A274369 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,
%T A274369 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,
%U A274369 -2,-2,-1,-1,-2,-2,-3,-3,-2,-2,-1,-1,-2,-2,-3
%N 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.
%H A274369 Rémy Sigrist, <a href="/A274369/b274369.txt">Table of n, a(n) for n = 0..15000</a>
%H A274369 Felix Fröhlich, <a href="/A274369/a274369.pdf">Coordinates of Langton's ant</a>.
%H A274369 Wikipedia, <a href="https://en.wikipedia.org/wiki/Langton%27s_ant">Langton's ant</a>.
%F A274369 a(n+104) = a(n) + 2 for n > 9975. - _Andrey Zabolotskiy_, Jul 05 2016
%o A274369 (Python)
%o A274369 # A274369: Langton's ant by _Andrey Zabolotskiy_, Jul 05 2016
%o A274369 def ant(n):
%o A274369     steps = [(1, 0), (0, 1), (-1, 0), (0, -1)]
%o A274369     black = set()
%o A274369     x = y = 0
%o A274369     position = [(x, y)]
%o A274369     direction = 2
%o A274369     for _ in range(n):
%o A274369         if (x, y) in black:
%o A274369             black.remove((x, y))
%o A274369             direction += 1
%o A274369         else:
%o A274369             black.add((x, y))
%o A274369             direction -= 1
%o A274369         (dx, dy) = steps[direction%4]
%o A274369         x += dx
%o A274369         y += dy
%o A274369         position.append((x, y))
%o A274369     return position
%o A274369 print([p[0] for p in ant(100)])
%o A274369 # change p[0] to p[1] to get y-coordinates
%Y A274369 Cf. A274370 (y-coordinate).
%Y A274369 Cf. A102358, A102369, A204810, A255938, A261990, A269757.
%K A274369 sign,look
%O A274369 0,21
%A A274369 _Felix Fröhlich_, Jun 19 2016