#include <stdio.h>

#define	MAXTRANSFORMS	5

typedef struct Transform
{
	int		orient;
	char	*moves;
} Transform;

typedef struct RubiksCube
{
	char Rubik2MikeFace[6];
	char Mike2RubikFace[6];
	int illegal, solved;
	
	char position[20];		/* What slot this piece is in */
	char orient[20];		/* What orientation it's in   */
	char slot[20];			/* What piece is in this slot */

	int stage;				/* What we're working on	  */
	
	int numTransforms;
	Transform	transforms[MAXTRANSFORMS];
	int transformIndex;		/* The transform we're doing  */
}
RubiksCube;


typedef struct CubeSide
{
	char	littleSquare[3][3];
} CubeSide;

typedef struct MikeCube
{
	CubeSide face[6];
} MikeCube;


int SolveRubiksCube(RubiksCube *);

void MikeCubeToRubiksCube(MikeCube *mikePtr,
  RubiksCube *rubikPtr);

void RubiksCubeToMikeCube(RubiksCube *rubikPtr,
  MikeCube *mikePtr);


/****************************/
/*							*/
/*	Rubik's Cube solution	*/
/*							*/
/*	By Robert A. Hearn		*/
/*							*/
/*	12/8/94					*/
/*							*/
/****************************/

#define VERBOSE 1

/*
	piece numbering:

	0	8	1	|	12	*	13	|	4	16	5
				|				|
	11	*	9	|	*	*	*	|	19	*	17
				|				|
	3	10 	2	|	15	* 	14	|	7	18	6
	
	top layer		middle layer	bottom layer	
*/

/* Stages */

enum { NONE, TOPCORNERS, TOPEDGES, POSBOTTOMCORNERS,
  ORIENTBOTTOMCORNERS, BOTTOMEDGES, POSMIDDLEEDGES,
  ORIENTMIDDLEEDGES };

static RubiksCube *TheCube;


static void DoTopCorner(int);
static void DoTopEdge(int);
static int PosBottomCorners(void);
static int OrientBottomCorners(void);
static void DoBottomEdge(int);
static int PosMiddleEdges(void);
static void OrientMiddleEdges(void);

static void TurnBottom(int);
static void TurnTop(int);
static void AddTransform(int, char *);
static int Solved(void);
static void DoTurn(int, char);
static void FindCorner(int);
static void FindEdge(int);

/*
MikeCube Mike = 
{	{
	{{	{ 0, 0, 5 },
		{ 0, 0, 5 },
		{ 0, 0, 5 }		}},
	{{	{ 1, 1, 1 },
		{ 1, 1, 1 },
		{ 1, 1, 1 }		}},
	{{	{ 2, 2, 0 },
		{ 2, 2, 0 },
		{ 2, 2, 0 }		}},
	{{	{ 3, 3, 3 },
		{ 3, 3, 3 },
		{ 3, 3, 3 }		}},
	{{	{ 4, 4, 2 },
		{ 4, 4, 2 },
		{ 4, 4, 2 }		}},
	{{	{ 5, 5, 4 },
		{ 5, 5, 4 },
		{ 5, 5, 4 }		}}
	}
};
*/


MikeCube Mike = 
{	{
	{{	{ 4, 1, 2 },
		{ 4, 0, 4 },
		{ 0, 5, 2 }		}},
	{{	{ 3, 3, 4 },
		{ 4, 2, 5 },
		{ 4, 2, 5 }		}},
	{{	{ 3, 2, 0 },
		{ 0, 5, 5 },
		{ 4, 0, 0 }		}},
	{{	{ 3, 5, 3 },
		{ 1, 4, 4 },
		{ 5, 2, 5 }		}},
	{{	{ 1, 3, 2 },
		{ 3, 1, 0 },
		{ 5, 1, 2 }		}},
	{{	{ 0, 3, 1 },
		{ 1, 3, 0 },
		{ 1, 2, 1 }		}}
	}
};


main()
{
RubiksCube cube;
int x, done = 0;
long ticks1, ticks2;
char s[10];

	printf("Hello!\n");
	MikeCubeToRubiksCube(&Mike, &cube);
	if (cube.illegal)
		printf("illegal\n");
	else
		printf("ok\n");

	ticks1 = TickCount();
	
	for (x = 0; x < 300 && !done; ++x)
		done = SolveRubiksCube(&cube);
	
	ticks2 = TickCount();
	
	if (done == -1)
		printf("illegal position\n");
	else
		printf("\n\n%d moves, %ld ticks.\n", x, ticks2 - ticks1);


/*	RubiksCubeToMikeCube(&cube, &Mike);
	
	printf("\n");
	
	for (x = 0; x < 3; ++x)
		printf("   %d%d%d\n", Mike.face[0].littleSquare[x][0], Mike.face[0].littleSquare[x][1], Mike.face[0].littleSquare[x][2]);
	for (x = 0; x < 3; ++x)
		printf("%d%d%d%d%d%d%d%d%d\n",
		  Mike.face[1].littleSquare[x][0], Mike.face[1].littleSquare[x][1], Mike.face[1].littleSquare[x][2],
		  Mike.face[2].littleSquare[x][0], Mike.face[2].littleSquare[x][1], Mike.face[2].littleSquare[x][2],
		  Mike.face[3].littleSquare[x][0], Mike.face[3].littleSquare[x][1], Mike.face[3].littleSquare[x][2]);
	for (x = 0; x < 3; ++x)
		printf("   %d%d%d\n", Mike.face[4].littleSquare[x][0], Mike.face[4].littleSquare[x][1], Mike.face[4].littleSquare[x][2]);
	for (x = 0; x < 3; ++x)
		printf("   %d%d%d\n", Mike.face[5].littleSquare[x][0], Mike.face[5].littleSquare[x][1], Mike.face[5].littleSquare[x][2]);
		*/
}


int SolveRubiksCube(RubiksCube *cubePtr)
{
int x, flipped;
Transform *transform;

	TheCube = cubePtr;
	
	if (TheCube->illegal)
		return -1;
		
	if (TheCube->solved)
		return 1;
		
	if (TheCube->transformIndex == TheCube->numTransforms)
	{
		/* Identify the next transform */
		
		TheCube->numTransforms = TheCube->transformIndex = 0;
		
		switch (TheCube->stage)
		{
			case NONE:
				TheCube->stage = TOPCORNERS;

				if (VERBOSE)
					printf("\nTop corners:\n");
			
			case TOPCORNERS:
				for (x = 0; x < 4; ++x)
					if (TheCube->position[x] != x || TheCube->orient[x])
					{
						DoTopCorner(x);
						break;
					}
					
				if (x < 4)
					break;
					
				TheCube->stage = TOPEDGES;

				if (VERBOSE)
					printf("\nTop edges:\n");
				
			case TOPEDGES:
				for (x = 8; x < 12; ++x)
					if (TheCube->position[x] != x || TheCube->orient[x])
					{
						DoTopEdge(x);
						break;
					}
					
				if (x < 12)
					break;
					
				TheCube->stage = POSBOTTOMCORNERS;

				if (VERBOSE)
					printf("\nPosition bottom corners:\n");
				
			case POSBOTTOMCORNERS:
				if (!PosBottomCorners())
					break;
				
				TheCube->stage = ORIENTBOTTOMCORNERS;

				if (VERBOSE)
					printf("\nOrient bottom corners:\n");
				
			case ORIENTBOTTOMCORNERS:
				if (!OrientBottomCorners())
					break;
				
				TheCube->stage = BOTTOMEDGES;

				if (VERBOSE)
					printf("\nBottom edges:\n");

			case BOTTOMEDGES:
				for (x = 16; x < 20; ++x)
					if (TheCube->position[x] != x || TheCube->orient[x])
					{
						DoBottomEdge(x);
						break;
					}
					
				if (x < 20)
					break;
					
				TheCube->stage = POSMIDDLEEDGES;

				if (VERBOSE)
					printf("\nPosition middle edges:\n");
				
			case POSMIDDLEEDGES:
				if (!PosMiddleEdges())
					break;
				
				/* Check for illegal position parity */
				
				if (TheCube->position[14] != 14)
					return -1;
					
				TheCube->stage = ORIENTMIDDLEEDGES;

				if (VERBOSE)
					printf("\nOrient middle edges:\n");

			case ORIENTMIDDLEEDGES:
				OrientMiddleEdges();
				break;
		}
		
	}
	
	if (TheCube->transformIndex == TheCube->numTransforms)
	{
		printf("\noops!\n");
		return -1;
	}
	
	transform = &TheCube->transforms[TheCube->transformIndex];
	DoTurn(transform->orient, *(transform->moves++));
	
	if (!*transform->moves)
	{
		if (VERBOSE)
			printf(" ");
			
		++TheCube->transformIndex;
		
		if (TheCube->transformIndex == TheCube->numTransforms && Solved())
			return 1;
	}
		
	return 0;
}


static void DoTopCorner(int corner)
{
int delta, orient;

	if (TheCube->position[corner] < 4)
	{
		/* If it's on the top, put it on the bottom. */
		
	/*	printf("\nput corner %d on bottom\n", corner);	*/
		
		AddTransform((TheCube->position[corner] + 2) % 4, "rdR");
		return;
	}
	
	orient = (corner + 2) % 4;
	
	if (TheCube->orient[corner] < 2)
	{
	/*	printf("\nput corner %d on top, case 1\n", corner);		*/
		
		TurnBottom(delta = (TheCube->position[corner] - corner + 3) % 4);
		AddTransform(orient, TheCube->orient[corner] ? "rDR" : "rDDRdrDR");
	}
	else
	{
/*		printf("\nput corner %d on top, case 2\n", corner);	*/
		
		TurnBottom(delta = (TheCube->position[corner] - corner + 1) % 4);
		AddTransform(orient, "Fdf");
	}
}


static void DoTopEdge(int edge)
{
int delta, orient;

/*	printf("\ndo edge %d\n", edge);	*/
	
	if (TheCube->position[edge] < 12)
	{
		AddTransform((TheCube->position[edge] + 2) % 4, "RlFLr");
		return;
	}
	
	orient = (edge + 2) % 4;

	if (TheCube->position[edge] < 16)
	{
		delta = (TheCube->position[edge] + 2 - TheCube->orient[edge] - edge) % 4;
		
	/*	TurnBottom((4 - delta) % 4);	*/
		TurnTop(delta);

		AddTransform((orient + delta) % 4, TheCube->orient[edge] ? "FuDrU" : "fUdLu");

		TurnTop((4 - delta) % 4);
	/*	TurnBottom(delta);	*/

		return;
	}
	
	delta = (TheCube->position[edge] - edge) % 4;
	
	if (!TheCube->orient[edge])
	{
		TurnBottom(delta);
		AddTransform(orient, "RlFFLr");
	}
	else
	{
		TurnBottom(delta % 2 ? 0 : 3);
		AddTransform(orient, delta > 1 ? "RlfrL" : "RlFrL");
	}
}


static int PosBottomCorners()
{
int x;

/*	printf("\npos bottom corners\n");	*/
	
	/* Are there two adjacent corners that are correctly placed?	*/
	
	for (x = 4; x < 8; ++x)
		if ((TheCube->slot[x] + 1) % 4 == TheCube->slot[4 + (x + 1) % 4] % 4)
		{
			/* Are the others correctly placed?	*/
			
			if (x == 4 && (TheCube->slot[5] + 1) % 4 == TheCube->slot[6] % 4)
			{
				if (TheCube->position[4] == 4)
					return 1;
					
				TurnBottom(TheCube->position[4] % 4);
				
				return 0;
			}

			AddTransform((x - 2) % 4, "LDlfDFLdl");
				
			return 0;
		}
		
	/* No.	*/
	
	AddTransform(0, "LDlfDDFLdl");
	return 0;
}


static int OrientBottomCorners()
{
int x, y, temp, badcorners;

	for (x = 4, badcorners = 0; x < 8; ++x)
		badcorners += !!TheCube->orient[x];
		
	if (!badcorners)
		return 1;
		
	if (badcorners > 2)	
		for (x = 4; x < 8; ++x)
			if (badcorners == 4 || (TheCube->orient[x] && !(TheCube->orient[4 + (x + 1) % 4])))
			{
				if (TheCube->orient[x] == 1)
					AddTransform((x + 1) % 4, "LDDldLdlDD");
				else if (TheCube->orient[x] == 2)
					AddTransform((x + 1) % 4, "LDlDLDDlDD");
				
				return 0;
			}

	for (x = 4; x < 7; ++x)
		if (TheCube->orient[x])
			for (y = x + 1; y < 8; ++y)
				if (TheCube->orient[y])
				{
					if (TheCube->orient[x] == 1)
					{
						temp = x;
						x = y;
						y = temp;
					}
					
					AddTransform((x + 3) % 4, "rURurUR");
					TurnBottom((y + 4 - x) % 4);
					AddTransform((x + 3) % 4, "ruRUruR");
					TurnBottom((x + 4 - y) % 4);
	
					return 0;
				}
}


static void DoBottomEdge(int edge)
{
int delta, orient;

/*	printf("\ndo edge %d\n", edge);	*/
	
	if (TheCube->position[edge] > 15)
	{
		AddTransform((TheCube->position[edge] + 2) % 4, "RFRUdFFuDRfr");
		return;
	}
	
	delta = (TheCube->position[edge] + 9 - TheCube->orient[edge] - edge) % 4;
	TurnBottom((4 - delta) % 4);
	AddTransform((edge + delta + 2) % 4, TheCube->orient[edge] ? "RFrdUffDurfr" : "RFRUdFFuDRfr");
	TurnBottom(delta);
}


static int PosMiddleEdges()
{
	if (TheCube->position[12] == 12)
	{
		if (TheCube->position[13] == 13)
			return 1;
			
		if (TheCube->position[13] == 14)
			AddTransform(0, "RRUdFFuD");
		else
			AddTransform(0, "FFuDRRUd");
	}
	else
		switch (TheCube->position[12])
		{
			case 13:
				AddTransform(0, "LLUdBBuD");
				break;
			case 14:
				AddTransform(0, "RRuDBBUd");
				break;
			case 15:
				AddTransform(0, "BBuDLLUd");
				break;
		}
	
	return 0;
}


static void OrientMiddleEdges()
{
int x;

	for (x = 12; x < 16; ++x)
		if (TheCube->orient[x])
		{
			if (TheCube->orient[12 + (x + 1) % 4])
			{
				if (TheCube->orient[12 + (x + 2) % 4])
					AddTransform(0, "FlfUdbUdrUdfUdlFLf");
				else
					AddTransform((x - 3) % 4, "UdbUdrUdfUdllUdbUdrUdfUd");
			}
			else if (TheCube->orient[12 + (x + 2) % 4])
				AddTransform((x - 3) % 4, "BBUdbUdrUdfUdllUdbUdrUdfUdBB");
			else
				AddTransform(x % 4, "UdbUdrUdfUdllUdbUdrUdfUd");
			
			break;
		}
}


static char *BottomMoves[] = { "", "D", "DD", "d" };

static void TurnBottom(int delta)
{
char *moves;

	if (delta)
		AddTransform(0, BottomMoves[delta]);
}


static char *TopMoves[] = { "", "U", "UU", "u" };

static void TurnTop(int delta)
{
char *moves;

	if (delta)
		AddTransform(0, TopMoves[delta]);
}


static void AddTransform(int orient, char *moves)
{
Transform trans;

	if (TheCube->numTransforms == MAXTRANSFORMS)
		printf("\Error: transform overflow\n");
		
	trans.orient = orient;
	trans.moves = moves;
	
	TheCube->transforms[TheCube->numTransforms++] = trans;
}


static int Solved()
{
int x;

	for (x = 0; x < 20; ++x)
		if (TheCube->position[x] != x || TheCube->orient[x])
			return 0;
			
	return 1;
}


static char MoveTable[] = { 0, 0, 5, 0, 2, 0, 0, 0,
  0, 0, 3, 0, 0, 0, 0, 0, 1, 0, 0, 4 };	/* 'B' to 'U' */

static char CornerPieces[6][4] =
{
	{ 1, 0, 4, 5 },
	{ 2, 1, 5, 6 },
	{ 3, 2, 6, 7 },	
	{ 0, 3, 7, 4 },
	{ 0, 1, 2, 3 },
	{ 7, 6, 5, 4 }
};

static char EdgePieces[6][4] =
{
	{ 8,  12, 16, 13 },
	{ 9,  13, 17, 14 },
	{ 10, 14, 18, 15 },
	{ 11, 15, 19, 12 },
	{ 8,  9,  10, 11 },
	{ 19, 18, 17, 16 }
};

char foo[] = "BRFLUD";
	
static void DoTurn(int moveorient, char move)
{
int temp;
register char *position = TheCube->position;
register char *orient = TheCube->orient;
register char *slot = TheCube->slot;
int a, b, c, d;
int ccw = move > 'Z';

	move = MoveTable[move - 'B' - (ccw ? 'a' - 'A' : 0)];
	if (move < 4)
		move = (move + moveorient) % 4;
	
	if (VERBOSE)
		printf("%c", foo[move] + ccw * ('a' - 'A'));
	
	/* do corners */
	
	a = CornerPieces[move][ccw ? 2 : 0];
	b = CornerPieces[move][ccw ? 1 : 1];
	c = CornerPieces[move][ccw ? 0 : 2];
	d = CornerPieces[move][ccw ? 3 : 3];
	
	temp = slot[d];
	position[slot[d] = slot[c]] = d;
	position[slot[c] = slot[b]] = c;
	position[slot[b] = slot[a]] = b;
	position[slot[a] = temp] = a;
	
	if (move < 4)
	{
		orient[slot[a]] = (orient[slot[a]] + 2) % 3;
		orient[slot[b]] = (orient[slot[b]] + 1) % 3;
		orient[slot[c]] = (orient[slot[c]] + 2) % 3;
		orient[slot[d]] = (orient[slot[d]] + 1) % 3;
	}
	
	/* do edges */

	a = EdgePieces[move][ccw * 2];
	b = EdgePieces[move][1];
	c = EdgePieces[move][(1 - ccw) * 2];
	d = EdgePieces[move][3];
	
	temp = slot[d];
	position[slot[d] = slot[c]] = d;
	position[slot[c] = slot[b]] = c;
	position[slot[b] = slot[a]] = b;
	position[slot[a] = temp] = a;
	
	if (move < 4)
	{
		orient[slot[b]] ^= 1;
		orient[slot[c]] ^= 1;
	}	
}


/********************************/
/*								*/
/*	Cube conversion routines	*/
/*								*/
/********************************/

static char CornerColors[8][3] = 
{
	{ 0, 1, 5 },
	{ 0, 5, 3 },
	{ 0, 3, 2 },
	{ 0, 2, 1 },
	{ 4, 5, 1 },
	{ 4, 3, 5 },
	{ 4, 2, 3 },
	{ 4, 1, 2 }
};

static char MikeCornerSquares[8][3][3] =
{
	{ { 0, 0, 0 }, { 1, 0, 0 }, { 5, 2, 0 } },
	{ { 0, 0, 2 }, { 5, 2, 2 }, { 3, 0, 2 } },
	{ { 0, 2, 2 }, { 3, 0, 0 }, { 2, 0, 2 } },
	{ { 0, 2, 0 }, { 2, 0, 0 }, { 1, 0, 2 } },
	{ { 4, 2, 0 }, { 5, 0, 0 }, { 1, 2, 0 } },
	{ { 4, 2, 2 }, { 3, 2, 2 }, { 5, 0, 2 } },
	{ { 4, 0, 2 }, { 2, 2, 2 }, { 3, 2, 0 } },
	{ { 4, 0, 0 }, { 1, 2, 2 }, { 2, 2, 0 } }
};

static char EdgeColors[12][2] =
{
	{ 0, 5 },
	{ 0, 3 },
	{ 0, 2 },
	{ 0, 1 },
	{ 5, 1 },
	{ 3, 5 },
	{ 2, 3 },
	{ 1, 2 },
	{ 4, 5 },
	{ 4, 3 },
	{ 4, 2 },
	{ 4, 1 }
};

static char MikeEdgeSquares[12][2][3] =
{
	{ { 0, 0, 1 }, { 5, 2, 1 } },
	{ { 0, 1, 2 }, { 3, 0, 1 } },
	{ { 0, 2, 1 }, { 2, 0, 1 } }, 
	{ { 0, 1, 0 }, { 1, 0, 1 } },
	{ { 5, 1, 0 }, { 1, 1, 0 } },
	{ { 3, 1, 2 }, { 5, 1, 2 } },
	{ { 2, 1, 2 }, { 3, 1, 0 } },
	{ { 1, 1, 2 }, { 2, 1, 0 } },
	{ { 4, 2, 1 }, { 5, 0, 1 } },
	{ { 4, 1, 2 }, { 3, 2, 1 } },
	{ { 4, 0, 1 }, { 2, 2, 1 } },
	{ { 4, 1, 0 }, { 1, 2, 1 } }
};

static MikeCube *TheMike;


void MikeCubeToRubiksCube(MikeCube *mikePtr, RubiksCube *rubikPtr)
{
int x, orient;

	TheCube = rubikPtr;
	TheMike = mikePtr;
	
	TheCube->illegal = 0;
	TheCube->stage = NONE;
	TheCube->numTransforms = TheCube->transformIndex = 0;
	
	for (x = 0; x < 6; ++x)
	{
		TheCube->Rubik2MikeFace[x] = TheMike->face[x].littleSquare[1][1];
		TheCube->Mike2RubikFace[TheMike->face[x].littleSquare[1][1]] = x;
	}

	for (x = 0; x < 8; ++x)
		FindCorner(x);

	for (x = 8; x < 20; ++x)
		FindEdge(x);

	/* check corner & edge parity */
	
	for (x = orient = 0; x < 8; ++x)
		orient += TheCube->orient[x];
		
	if (orient % 3)
	{
		printf("Corner parity %d\n", orient);
		TheCube->illegal = 1;
	}

	for (x = 8, orient = 0; x < 20; ++x)
		orient += TheCube->orient[x];
		
	if (orient % 2)
	{
		printf("Edge parity %d\n", orient);
		TheCube->illegal = 1;
	}

	TheCube->solved = Solved();
}


static void FindCorner(int slot)
{
char temp, orient = 0;
int x;
char color[3];
char *face;

	for (x = 0; x < 3; ++x)
	{
		face = MikeCornerSquares[slot][x];
		color[x] = TheCube->Mike2RubikFace[TheMike->face
		  [face[0]].littleSquare[face[1]][face[2]]];
	}
	
	if (!color[1] || color[1] == 4)
	{
		temp = color[1];
		color[1] = color[2];
		color[2] = color[0];
		color[0] = temp;
		orient = 1;
	}
	else if (!color[2] || color[2] == 4)
	{
		temp = color[2];
		color[2] = color[1];
		color[1] = color[0];
		color[0] = temp;
		orient = 2;
	}
	
	for (x = 0; x < 8; ++x)
		if (CornerColors[x][0] == color[0] && 
		  CornerColors[x][1] == color[1] && 
		  CornerColors[x][2] == color[2])
		{
			TheCube->slot[slot] = x;
			TheCube->position[x] = slot;
			TheCube->orient[x] = orient;
			
			return;
		}
		
	printf("can't find %d, %d, %d [%d]\n", color[0], color[1], color[2], slot);

	TheCube->illegal = 1;
}


static void FindEdge(int slot)
{
int x;
char color[2];
char *face;

	for (x = 0; x < 2; ++x)
	{
		face = MikeEdgeSquares[slot - 8][x];
		color[x] = TheCube->Mike2RubikFace[TheMike->face
		  [face[0]].littleSquare[face[1]][face[2]]];
	}
	
	for (x = 0; x < 12; ++x)
		if ((EdgeColors[x][0] == color[0] && EdgeColors[x][1] == color[1]) ||
		  (EdgeColors[x][1] == color[0] && EdgeColors[x][0] == color[1]))
		{
			TheCube->slot[slot] = x + 8;
			TheCube->position[x + 8] = slot;
			TheCube->orient[x + 8] = (EdgeColors[x][1] == color[0]);
			
			return;
		}
		
	printf("can't find %d, %d [%d]\n", color[0], color[1], slot);
	
	TheCube->illegal = 1;
}


void RubiksCubeToMikeCube(RubiksCube *rubikPtr, MikeCube *mikePtr)
{
int x, y;
char *face;

	for (x = 0; x < 6; ++x)
		mikePtr->face[x].littleSquare[1][1] = rubikPtr->Rubik2MikeFace[x];
		
	for (x = 0; x < 8; ++x)
		for (y = 0; y < 3; ++y)
		{
			face = MikeCornerSquares[rubikPtr->position[x]][y];
			mikePtr->face[face[0]].littleSquare[face[1]][face[2]] = rubikPtr->
			  Rubik2MikeFace[CornerColors[x][(y + 3 - rubikPtr->orient[x]) % 3]];
		}
		
	for (x = 8; x < 20; ++x)
		for (y = 0; y < 2; ++y)
		{
			face = MikeEdgeSquares[rubikPtr->position[x] - 8][y];
			mikePtr->face[face[0]].littleSquare[face[1]][face[2]] = rubikPtr->
			  Rubik2MikeFace[EdgeColors[x - 8][(y + rubikPtr->orient[x]) % 2]];
		}
}
