I’m looking for a generic algorithm which, given the range values start and end will generate a list of numbers, but the numbers must go through zero..
Here’s my current code:
end = 78
start = -1 * end
step_size = 16
numbers = range(start, end+step_size, step_size)
$ numbers
Out[90]: [-78, -62, -46, -30, -14, 2, 18, 34, 50, 66, 82]
so in this particular case, I would subtract 2 from each number, so that the numbers have one zero value. But how could I do this more generally? I’m doing this to calculate the y-tic locations of a graph, and therefore I want them to go through zero once.
start % step_sizeshould be the required offset:Examples: