The answer should be 25. My "proof" is a brute force programming solution. I have a psuedocode c++ bruteforce solution. I can give the full version
if requested. It takes a few seconds to brute force all possible paths. This might count as a proof, depending on if you trust the computer
to be reliable.
Basically what it does is it generates all possible paths, and then prunes as it goes along so the program dosen't take basically forever, or 6^27 moves.
Now a proof will involve some theorems in graph theory, which I don't yet know all that well.
Assume the XYZ plane
void recursive_dumb_solution( A 3D cube,Position of X, Y, and Z of current spot,direction it went twice ago, direction it went to get here){
if traveled along a direction twice in a row, return to the above function.
else if( x<0 || x > 2 || y < 0 || y > 2 || z < 0 || z > 2) AKA if it exited the cube, return.
else if(cube[x][y][z] == 1) AKA if visited spot already visited, then return.
else{
//mark the current position of the cube as visited.
cube[x][y][z] = 1;
/////Moves in every direction possible.
recursive_dumb_solution(cube, x+1, y, z, length+1,'x',prev_dir);
recursive_dumb_solution(cube, x-1, y, z, length+1,'x',prev_dir);
recursive_dumb_solution(cube, x, y+1, z, length+1,'y',prev_dir);
recursive_dumb_solution(cube, x, y-1, z, length+1,'y',prev_dir);
recursive_dumb_solution(cube, x, y, z+1, length+1,'z',prev_dir);
recursive_dumb_solution(cube, x, y, z-1, length+1,'z',prev_dir);
cube[x][y][z] = 0;
return;
}
}