You're with your best bud, Jim, at the amusement park and as your favorite ride comes into view, you and Jim exchange glances. Naturally you race to get in line. Unfortunately he wins because you're a golfer and he plays a real sport (sorry friends). In fact, you're so far behind that you and Jim are separated by x
people. Assuming the line is length n
and you're at the back and the line zigs and zags every j
people, at what positions in the line will you and Jim be in the same column allowing you to chat (only one row apart)?
Input
3 Integers
n
- The length of the line. This number will always be greater than or equal toj
and will be in the formy * j
wherey
is a positive integer (the number of rows in the queue).j
- The number of people in one row of the line (the number of columns in one row). This number will always be greater than 0.x
- The number of people between you and Jim such that0 <= x < 2j - 1
. Hint: If this number is odd, then your output should be empty.
Output
A list of integer positions in the line at which Jim is in the same column as you.
1 These integers can be 0 or 1-indexed as long as you specify in your answer.
2 These integers can assume you start at position 0 or position n-1 as long as you specify in your answer.
Example
In this example, the input would be n = 9, j = 3, x = 0
. The output should be 2, 5
because your position is 2 or 5 when you're in the same column as Jim
Test Cases
[9, 3, 0] -> [2, 5]
[12, 3, 0] -> [2, 5, 8]
[9, 3, 1] -> []
[9, 3, 2] -> [1, 4]
[14, 7, 10] -> [1]
[24, 4, 6] -> [0, 4, 8, 12, 16]
Scoring
This is code-golf, so the shortest answer (in bytes) wins.