login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A213088 The Manhattan distance to the origin while traversing the first quadrant in a taxicab geometry. 0

%I #13 May 09 2021 09:52:02

%S 0,1,2,1,2,3,4,3,2,3,4,5,6,5,4,3,4,5,6,7,8,7,6,5,4,5,6,7,8,9,10,9,8,7,

%T 6,5,6,7,8,9,10,11,12,11,10,9,8,7,6,7,8,9,10,11,12,13,14,13,12,11,10,

%U 9,8,7,8,9,10,11,12,13,14,15,16,15,14,13,12,11

%N The Manhattan distance to the origin while traversing the first quadrant in a taxicab geometry.

%o (Python)

%o def f(x, y):

%o if not x and y % 2:

%o y = y + 1

%o elif not y and not x % 2:

%o x = x + 1

%o elif x == y:

%o if x % 2:

%o x = x - 1

%o else:

%o y = y - 1

%o elif y < x:

%o if x % 2:

%o y = y + 1

%o else:

%o y = y - 1

%o else:

%o if y % 2:

%o x = x - 1

%o else:

%o x = x + 1

%o return x, y

%o res = []

%o x = y = 0

%o for i in range(100):

%o res.append(x + y)

%o x, y = f(x, y)

%o print(res)

%K nonn,walk

%O 1,3

%A _Jens Ahlström_, Jun 05 2012

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

License Agreements, Terms of Use, Privacy Policy. .

Last modified May 9 10:34 EDT 2024. Contains 372350 sequences. (Running on oeis4.)