Assuming a 3 dimensional irregular matrix where y = 1.5(x) and z = .5(y)
.
Further assuming an object starts at 0,0,0
and must move positively in at least two dimensions, and must move in all three dimensions (x+1, y+1, z-1
is okay, x+1, y+1, z=z
is not). It may move any number of "spaces", but must move the same number in all directions.
The object is allowed to wraparound (x(max +1) = x(0))
.
Move said object from its starting position to (0, max(y), .5(max(z)))
For z
, round up for fractions (end point in 4, 6, 3 matrix becomes 0, 6, 2)
Input is an Integer (X).
Output is the list of moves you would make (extra credit for showing the number of spaces you moved)
Sample Input/Output:
X = 4
Y = 6 //(4 * 1.5)
Z = 3 // 6 / 2
0, 0, 0 //Start
2, 5, 2 // (+2, -2, +2)
1, 2, 2 // (+4, +4, +4)
3, 4, 0 // (+2, +2, -2)
1, 6, 2 // (-2, +2, +2)
3, 3, 3 // (-3, -3, -3)
1, 5, 1 // (-2, +2, -2)
0, 6, 2 // (-1, +1, -1)
7 Moves.
Lua, 68 Characters
The long version below always solves the problem with one move by searching for the first all positive move that will solve problem.
Output for x = 12:
Output for x = 1000:
Seems like the search could be replaced with some simple algebraic equation. But why stop there? Rules are easier to bend in golfing then doing the actual work.
So, assuming that there is always a single 1 move answer, and that I do not have to disclose the "number of spaces you moved", here is the 68 character golfed answer: