OFFSET
1,2
COMMENTS
See A350578 for further details.
EXAMPLE
MATHEMATICA
a[0]=0; a[n_]:=a[n]=If[a[n-1]-n>=0&&Count[Array[a, n-1, 0], a[n-1]-n]<=Count[Array[a, n-1, 0], a[n-1]+n], a[n-1]-n, a[n-1]+n];
Table[k=0; While[Max[Last/@(c=Tally@Array[a, ++k, 0])]!=i]; a[k-1], {i, 6}] (* Giorgos Kalogeropoulos, Jan 07 2022 *)
PROG
(Python)
from itertools import count
from collections import Counter
def A350579(n):
b, bcounter = 0, Counter({0})
for m in count(1):
if bcounter[b] == n: return b
b += -m if b-m >= 0 and bcounter[b-m] <= bcounter[b+m] else m
bcounter[b] += 1 # Chai Wah Wu, Jan 08 2022
CROSSREFS
KEYWORD
nonn
AUTHOR
Scott R. Shannon, Jan 07 2022
STATUS
approved