The world is a five by five array of cells. It wraps on all sides. It can be visualized like...
XXXXX XXXXX XXOXX XXXXX XXXXX
You are an O. You love to travel the world, and you do so according to the following rules (let C be the current day):
- On prime days, you feel nostalgic. Return to where you started yesterday.
- On odd days, you feel homesick. Move one horizontal step closer to home, if possible, and one vertical step closer to home, if possible. Ignore world wrapping for the purpose determining closeness.
- On even days, you feel adventurous. Move C / 2 steps south.
- On square days, you feel adventurous. Move to the east wall.
- On Fibonacci days, the world expands southward by one row.
- On triangular days, the world expands eastward by one column.
If two or more of the above rules would apply at the same time, apply them in the order listed. For example, on an odd prime day, first return to where you started yesterday, and then move one step closer to home.
You live at the center of the (initial) world, i.e. position (2,2), zero-indexed from the Northwest corner. You begin your journey there on day one.
A single integer, N.
Your X and Y coordinate on the Nth day, zero-indexed from the Northwest corner, separated by a single space.
Test Case With Explanation
Given an input of
3, the correct output is:
We can work through this one day at a time. Starting on day 1, we need to apply the following moves:
- Odd, square, Fibonacci, and triangular
- Prime, even, and Fibonacci
- Prime, odd, Fibonacci, and triangular
In visual form:
Day 1 Day 2 Day 3 XXXXX XXXXXX XXXXXX XXXXXXX XXXXX XXXXXX XXXXXX XXXXXXX XXOXX -> XXXXOX -> XXXXXX -> XXXOXXX XXXXX XXXXXX XXOXXX XXXXXXX XXXXX XXXXXX XXXXXX XXXXXXX XXXXXX XXXXXX XXXXXXX XXXXXX XXXXXXX XXXXXXX
Additional Test Cases
Input: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 Output: 4 2 2 3 3 2 6 4 2 2 2 5 2 2 2 6 7 5 7 0 6 4 6 0 5 3 5 10 4 9 9 6 3 8 3 6 2 7 2 6 2 5 2 4 2 4
This is code golf. The shortest submission wins.