• 0
Sign in to follow this  
Followers 0

Touring the chessboard with a single die

Question

Posted · Report post

I read this one a while back and found it challenging.

Place a single die on QR8 of a chessboard, or a smaller 8x8 grid of squares.

The die "moves" from square to square by tipping on its side in a N, E, S or W direction,

[thus] making a 1/4 turn each time it moves to a new square.

The object is for the die to move to each of the squares, only once, and finish on KR8.

That is to tour the board beginning on the NW corner and end on the NE corner.

The final constraint is that the 1-spot must be up on the beginning and ending squares,

but on none of the intervening squares.

To describe the tour, number the board left to right so that the top row (8th rank)

Is 1 2 3 4 5 6 7 8 and the bottom row (1st rank) is 57 58 59 60 61 62 63 64.

Again, begin on square 1, and end on square 8.

0

Share this post


Link to post
Share on other sites

9 answers to this question

  • 0

Posted · Report post

I understand the die tipping over onto an adjacent face. Is that the "1/4 turn" you mention, or is there an additional quarter turn (ie, on some other axis)

0

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

I understand the die tipping over onto an adjacent face. Is that the "1/4 turn" you mention, or is there an additional quarter turn (ie, on some other axis)

That is the only turn. OP edited to clarify that point.

0

Share this post


Link to post
Share on other sites
  • 0

Posted (edited) · Report post


1  2  3  4  5  6  7 64

14 13 12 11 10  9  8 63

15 16 17 18 19 20 21 62

28 27 26 25 24 23 22 61

29 30 31 32 33 34 35 60

42 41 40 39 38 37 36 59

43 46 47 50 51 54 55 58

44 45 48 49 52 53 56 57

Edited by phil1882
0

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post


1  2  3  4  5  6  7 64

14 13 12 11 10  9  8 63

15 16 17 18 19 20 21 62

28 27 26 25 24 23 22 61

29 30 31 32 33 34 35 60

42 41 40 39 38 37 36 59

43 46 47 50 51 54 55 58

44 45 48 49 52 53 56 57

At position 5 the 1 is on top of the die again breaking that constraint. Unless, that is, if I'm misreading the constraints.

0

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

ah your right i feel silly now.

0

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

It's funny, I was thinking it would probably be symmetrical... and it was.


_________________

|1=>=6=< >=6=<=1|

| X X X|X|X X X |

|>=6 6=< >=6 6=<|

||X|X|X X X|X|X||

|> ^=^ v=v ^=^ <|

||X X X|X|X X X||

|> >=6 6 6 6=< <|

||X|X|X|X|X|X|X||

|> > ^=^ ^=^ < <|

||X|X X X X X|X||

|> >=6=< >=6=< <|

||X X X|X|X X X||

|> v=v < > v=v <|

||X|X|X|X|X|X|X||

|>=6 6=< >=6 6=<|

-----------------

1 means 1 pip is showing, 6 means 6 pips are showing. ^ means the 1 is pointing towards the top of the grid, etc. Just follow the = and |. It's sad though. I almost had the solution (if I had assumed it was symmetrical), except for the cactus-like shape in the center. Then I got bored and wrote a backtracking search. Should've tried a while longer. For those interested, here is more code:
wasd to move die (press key then enter). (w-up, a-left, s-down, d-right). Space to undo. k to have it find a solution by backtracking.
#include <stdio.h>

#include <stdlib.h>

#include <iostream>

#include <memory.h>

#include <vector>



using namespace std;

#define GRIDSIZE 8


enum dir

{

	dir_front = 0,

	dir_back = 1,

	dir_up = 2,

	dir_down = 3,

	dir_right = 4,

	dir_left = 5,

	num_dirs = 6,

	dir_error = 7,

	dir_undo = 8

};


dir facing[GRIDSIZE*GRIDSIZE];

dir move[GRIDSIZE*GRIDSIZE];

vector<int> hist;

int displacement[8] = {0,0,-GRIDSIZE,GRIDSIZE,1,-1,0,0};





dir tiltarray[] =	 {dir_error,dir_error,dir_up,dir_down,dir_right,dir_left,

			dir_error,dir_error,dir_down,dir_up,dir_left,dir_right,

			dir_error,dir_error,dir_back,dir_front,dir_up,dir_up,

			dir_error,dir_error,dir_front,dir_back,dir_down,dir_down,

			dir_error,dir_error,dir_right,dir_right,dir_back,dir_front,

			dir_error,dir_error,dir_left,dir_left,dir_front,dir_back,

			dir_error,dir_error,dir_error,dir_error,dir_error,dir_error,

			dir_error,dir_error,dir_error,dir_error,dir_error,dir_error};

dir tilt(dir cur, dir tiltdir)

{

	int val = cur*num_dirs+tiltdir;

	return tiltarray[val];

}




void printdir(dir cur)

{

	switch (cur)

	{

		case dir_front:

			cout << "1";

			break;

		case dir_back:

			cout << "6";

			break;

		case dir_up:

			cout << "^";

			break;

		case dir_down:

			cout << "v";

			break;

		case dir_right:

			cout << ">";

			break;

		case dir_left:

			cout << "<";

			break;

		default:

			cout << " ";

			break;

	}


}


void drawgrid()

{

	for(int i = 0; i < GRIDSIZE*2+1; i++) cout << "_";

	cout << endl;

	for(int j = 0; j < GRIDSIZE; j++)

	{

		cout << "|";

		for(int i = 0; i < GRIDSIZE; i++)

		{

			printdir(facing[j*GRIDSIZE+i]);

			//printdir(move[j*GRIDSIZE+i]);


			if (i <= GRIDSIZE-2)

			{

				if ((move[j*GRIDSIZE+i]==dir_right) || (move[j*GRIDSIZE+i+1]==dir_left))

				{

					cout << "=";

				}

				else

				{

					cout << " ";

				}

			}


		}

		cout << "|" << endl;


		if (j <= GRIDSIZE-2)

		{

			cout << "|";

			for(int i = 0; i < GRIDSIZE; i++)

			{

				if ((move[j*GRIDSIZE+i]==dir_down) || (move[(j+1)*GRIDSIZE+i]==dir_up))

				{

					cout << "|";

				}

				else

				{

					cout << " ";

				}

				if (i < GRIDSIZE-1) cout << "X";

			}

			cout << "|" << endl;

		}

	}

	for(int i = 0; i < GRIDSIZE*2+1; i++) cout << "-";

	cout << endl;

}


int validmove(dir tiltdir, int verbose)

{

	if (((tiltdir==dir_up)&&(hist.back()<GRIDSIZE)) ||

   	 ((tiltdir==dir_down)&&(hist.back()>=(GRIDSIZE-1)*GRIDSIZE)) ||

   	 ((tiltdir==dir_right)&&(hist.back()%GRIDSIZE==GRIDSIZE-1)) ||

   	 ((tiltdir==dir_left)&&(hist.back()%GRIDSIZE==0)))

	{

		if (verbose) cout << "Invalid move: Boundary hit." << endl;

		return 0;

	}

	if (facing[hist.back()+displacement[tiltdir]] != dir_error)

	{

		if (verbose) cout << "Invalid move: Repeating a square." << endl;

		return 0;

	}

	if ((tilt(facing[hist.back()],tiltdir)==dir_front) && (hist.back()+displacement[tiltdir] != GRIDSIZE-1))

	{

		if (verbose) cout << "Invalid move: 1 would be facing up." << endl;

		return 0;

	}

	return 1;

}


int solved()

{

	if ((hist.size()==GRIDSIZE*GRIDSIZE) &&

		(hist.back()==GRIDSIZE-1) &&

		(facing[hist.back()] == dir_front))

		return 1;

	return 0;

}







int main(int argc, char *argv[])

{



	hist.push_back(0);


	for(int i = 0; i < GRIDSIZE*GRIDSIZE; i++)

	{

		facing[i] = dir_error;

		move[i] = dir_error;

	}

	facing[0] = dir_front;


	drawgrid();

	while (1)

	{

		int ch = getchar();

		dir tiltdir = dir_error;


		switch (ch)

		{

			case 'w'://up

				tiltdir = dir_up;

				break;

			case 's'://down

				tiltdir = dir_down;

				break;

			case 'd'://right

				tiltdir = dir_right;

				break;

			case 'a'://left

				tiltdir = dir_left;

				break;

			case ' '://undo

				tiltdir = dir_undo;

				break;

			case 'k'://solve it

				hist.clear();

				hist.push_back(0);

				for(int i = 0; i < GRIDSIZE*GRIDSIZE; i++)

				{

					facing[i] = dir_error;

					move[i] = dir_error;

				}

				facing[0] = dir_front;

				hist.reserve(GRIDSIZE*GRIDSIZE+1);

				while(!solved() && hist.size() > 0)

				{

					//if (hist.size() > GRIDSIZE*(GRIDSIZE-1)+6)

					//{

					//	drawgrid();

					//	getchar();

					//}

					dir nextone = dir_error;

					switch(move[hist.back()])

					{

						case dir_error: nextone = dir_up; break;

						case dir_up: nextone = dir_down; break;

						case dir_down: nextone = dir_right; break;

						case dir_right: nextone = dir_left; break;

						case dir_left: nextone = dir_undo; break;

						default:

							cout << "Should never get here!!" << endl;

					}

					if (nextone == dir_undo)

					{

						if (hist.size() <= 1) break;

						facing[hist.back()] = dir_error;

						move[hist.back()] = dir_error;

						hist.pop_back();

						continue;

					}

					move[hist.back()] = nextone;

					if (validmove(nextone,0))

					{

						dir temp = tilt(facing[hist.back()],nextone);

						hist.push_back(hist.back()+displacement[nextone]);

						facing[hist.back()] = temp;

						move[hist.back()] = dir_error;

					}

				}

				if (solved()) cout << "Found solution!" << endl;

				else cout << "No solution??" << endl;

				 drawgrid();

				break;

			default:

				break;

		}


		if (tiltdir == dir_error) continue;


		if (tiltdir == dir_undo)

		{

			if (hist.size() <= 1) continue;

			facing[hist.back()] = dir_error;

			hist.pop_back();

			move[hist.back()] = dir_error;

			drawgrid();

			continue;

		}



		if (validmove(tiltdir,1))

		{

			move[hist.back()] = tiltdir;

			dir temp = tilt(facing[hist.back()],tiltdir);

			hist.push_back(hist.back()+displacement[tiltdir]);

			facing[hist.back()] = temp;

		}


		drawgrid();

	}


}

1

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

It's funny, I was thinking it would probably be symmetrical... and it was.


_________________
|1=>=6=< >=6=<=1|
| X X X|X|X X X |
|>=6 6=< >=6 6=<|
||X|X|X X X|X|X||
|> ^=^ v=v ^=^ <|
||X X X|X|X X X||
|> >=6 6 6 6=< <|
||X|X|X|X|X|X|X||
|> > ^=^ ^=^ < <|
||X|X X X X X|X||
|> >=6=< >=6=< <|
||X X X|X|X X X||
|> v=v < > v=v <|
||X|X|X|X|X|X|X||
|>=6 6=< >=6 6=<|
-----------------



1 means 1 pip is showing, 6 means 6 pips are showing.

^ means the 1 is pointing towards the top of the grid, etc.

Just follow the = and |.



It's sad though.  I almost had the solution (if I had assumed it was symmetrical), except for the cactus-like shape in the center.  Then I got bored and wrote a backtracking search.  Should've tried a while longer.



For those interested, here is more code:

wasd to move die (press key then enter). (w-up, a-left, s-down, d-right). Space to undo. k to have it find a solution by backtracking.

#include <stdlib.h>
#include <iostream>
#include <memory.h>
#include <vector>


using namespace std;
#define GRIDSIZE 8

enum dir
{
dir_front = 0,
dir_back = 1,
dir_up = 2,
dir_down = 3,
dir_right = 4,
dir_left = 5,
num_dirs = 6,
dir_error = 7,
dir_undo = 8
};

dir facing[GRIDSIZE*GRIDSIZE];
dir move[GRIDSIZE*GRIDSIZE];
vector<int> hist;
int displacement[8] = {0,0,-GRIDSIZE,GRIDSIZE,1,-1,0,0};




dir tiltarray[] = {dir_error,dir_error,dir_up,dir_down,dir_right,dir_left,
dir_error,dir_error,dir_down,dir_up,dir_left,dir_right,
dir_error,dir_error,dir_back,dir_front,dir_up,dir_up,
dir_error,dir_error,dir_front,dir_back,dir_down,dir_down,
dir_error,dir_error,dir_right,dir_right,dir_back,dir_front,
dir_error,dir_error,dir_left,dir_left,dir_front,dir_back,
dir_error,dir_error,dir_error,dir_error,dir_error,dir_error,
dir_error,dir_error,dir_error,dir_error,dir_error,dir_error};
dir tilt(dir cur, dir tiltdir)
{
int val = cur*num_dirs+tiltdir;
return tiltarray[val];
}



void printdir(dir cur)
{
switch (cur)
{
case dir_front:
cout << "1";
break;
case dir_back:
cout << "6";
break;
case dir_up:
cout << "^";
break;
case dir_down:
cout << "v";
break;
case dir_right:
cout << ">";
break;
case dir_left:
cout << "<";
break;
default:
cout << " ";
break;
}

}

void drawgrid()
{
for(int i = 0; i < GRIDSIZE*2+1; i++) cout << "_";
cout << endl;
for(int j = 0; j < GRIDSIZE; j++)
{
cout << "|";
for(int i = 0; i < GRIDSIZE; i++)
{
printdir(facing[j*GRIDSIZE+i]);
//printdir(move[j*GRIDSIZE+i]);

if (i <= GRIDSIZE-2)
{
if ((move[j*GRIDSIZE+i]==dir_right) || (move[j*GRIDSIZE+i+1]==dir_left))
{
cout << "=";
}
else
{
cout << " ";
}
}

}
cout << "|" << endl;

if (j <= GRIDSIZE-2)
{
cout << "|";
for(int i = 0; i < GRIDSIZE; i++)
{
if ((move[j*GRIDSIZE+i]==dir_down) || (move[(j+1)*GRIDSIZE+i]==dir_up))
{
cout << "|";
}
else
{
cout << " ";
}
if (i < GRIDSIZE-1) cout << "X";
}
cout << "|" << endl;
}
}
for(int i = 0; i < GRIDSIZE*2+1; i++) cout << "-";
cout << endl;
}

int validmove(dir tiltdir, int verbose)
{
if (((tiltdir==dir_up)&&(hist.back()<GRIDSIZE)) ||
((tiltdir==dir_down)&&(hist.back()>=(GRIDSIZE-1)*GRIDSIZE)) ||
((tiltdir==dir_right)&&(hist.back()%GRIDSIZE==GRIDSIZE-1)) ||
((tiltdir==dir_left)&&(hist.back()%GRIDSIZE==0)))
{
if (verbose) cout << "Invalid move: Boundary hit." << endl;
return 0;
}
if (facing[hist.back()+displacement[tiltdir]] != dir_error)
{
if (verbose) cout << "Invalid move: Repeating a square." << endl;
return 0;
}
if ((tilt(facing[hist.back()],tiltdir)==dir_front) && (hist.back()+displacement[tiltdir] != GRIDSIZE-1))
{
if (verbose) cout << "Invalid move: 1 would be facing up." << endl;
return 0;
}
return 1;
}

int solved()
{
if ((hist.size()==GRIDSIZE*GRIDSIZE) &&
(hist.back()==GRIDSIZE-1) &&
(facing[hist.back()] == dir_front))
return 1;
return 0;
}






int main(int argc, char *argv[])
{


hist.push_back(0);

for(int i = 0; i < GRIDSIZE*GRIDSIZE; i++)
{
facing[i] = dir_error;
move[i] = dir_error;
}
facing[0] = dir_front;

drawgrid();
while (1)
{
int ch = getchar();
dir tiltdir = dir_error;

switch (ch)
{
case 'w'://up
tiltdir = dir_up;
break;
case 's'://down
tiltdir = dir_down;
break;
case 'd'://right
tiltdir = dir_right;
break;
case 'a'://left
tiltdir = dir_left;
break;
case ' '://undo
tiltdir = dir_undo;
break;
case 'k'://solve it
hist.clear();
hist.push_back(0);
for(int i = 0; i < GRIDSIZE*GRIDSIZE; i++)
{
facing[i] = dir_error;
move[i] = dir_error;
}
facing[0] = dir_front;
hist.reserve(GRIDSIZE*GRIDSIZE+1);
while(!solved() && hist.size() > 0)
{
//if (hist.size() > GRIDSIZE*(GRIDSIZE-1)+6)
//{
// drawgrid();
// getchar();
//}
dir nextone = dir_error;
switch(move[hist.back()])
{
case dir_error: nextone = dir_up; break;
case dir_up: nextone = dir_down; break;
case dir_down: nextone = dir_right; break;
case dir_right: nextone = dir_left; break;
case dir_left: nextone = dir_undo; break;
default:
cout << "Should never get here!!" << endl;
}
if (nextone == dir_undo)
{
if (hist.size() <= 1) break;
facing[hist.back()] = dir_error;
move[hist.back()] = dir_error;
hist.pop_back();
continue;
}
move[hist.back()] = nextone;
if (validmove(nextone,0))
{
dir temp = tilt(facing[hist.back()],nextone);
hist.push_back(hist.back()+displacement[nextone]);
facing[hist.back()] = temp;
move[hist.back()] = dir_error;
}
}
if (solved()) cout << "Found solution!" << endl;
else cout << "No solution??" << endl;
drawgrid();
break;
default:
break;
}

if (tiltdir == dir_error) continue;

if (tiltdir == dir_undo)
{
if (hist.size() <= 1) continue;
facing[hist.back()] = dir_error;
hist.pop_back();
move[hist.back()] = dir_error;
drawgrid();
continue;
}


if (validmove(tiltdir,1))
{
move[hist.back()] = tiltdir;
dir temp = tilt(facing[hist.back()],tiltdir);
hist.push_back(hist.back()+displacement[tiltdir]);
facing[hist.back()] = temp;
}

drawgrid();
}

}
#include <stdio.h>

Very nice, EventHorizon! I was just about to write a backtracking program when I saw that you beat me to it.

I was going to have mine check to see if there were any other ending grid squares besides square 8.

I never programmed in C++, so I can't decipher your code. I ran it and it took about 3 minutes on my

machine to come up with the solution you posted. Would it be easy to modify your code so that it looks

for endpoints (with the 1 up) other than square 8? Congrats!

0

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Very nice, EventHorizon! I was just about to write a backtracking program when I saw that you beat me to it.

I was going to have mine check to see if there were any other ending grid squares besides square 8.

I never programmed in C++, so I can't decipher your code. I ran it and it took about 3 minutes on my

machine to come up with the solution you posted. Would it be easy to modify your code so that it looks

for endpoints (with the 1 up) other than square 8? Congrats!

Yeah, it would be easy. So easy in fact... that here it is :)

First, I removed "(hist.back()==GRIDSIZE-1) &&" from if statement's condition in the solved() method. This statement means that a solution needs to end in position GRIDSIZE-1 (top right corner).

I got rid of "!solved() &&" in the condition in the while loop that does the backtracking. This will just let it keep going through all possibilities. (I could have just changed it to while(1) since the other condition is never used anyway (it'll hit a break statement first)).

I added the following block, used to print the solutions found, right after making a valid move (the last move if it results in a solution).

if (solved())

{

		cout << "Found one!" << endl;

		drawgrid();

}
And I removed the statements saying whether the solution was found after the loop and replaced it with one saying "Done!" I also needed to change the code in the validmove() method that prevents the 1 from showing up in intermediate spots from "&& (hist.back()+displacement[tiltdir] != GRIDSIZE-1)" to "&& (hist.size() != GRIDSIZE*GRIDSIZE-1)" in the validmove method. So if you've already covered 63 squares, then you can finally let the 1 face forward (instead of just allowing it in the top corner).
#include <stdio.h>

#include <stdlib.h>

#include <iostream>

#include <memory.h>

#include <vector>



using namespace std;

#define GRIDSIZE 8


enum dir

{

	dir_front = 0,

	dir_back = 1,

	dir_up = 2,

	dir_down = 3,

	dir_right = 4,

	dir_left = 5,

	num_dirs = 6,

	dir_error = 7,

	dir_undo = 8

};


dir facing[GRIDSIZE*GRIDSIZE];

dir move[GRIDSIZE*GRIDSIZE];

vector<int> hist;

int displacement[8] = {0,0,-GRIDSIZE,GRIDSIZE,1,-1,0,0};





dir tiltarray[] =	 {dir_error,dir_error,dir_up,dir_down,dir_right,dir_left,

			dir_error,dir_error,dir_down,dir_up,dir_left,dir_right,

			dir_error,dir_error,dir_back,dir_front,dir_up,dir_up,

			dir_error,dir_error,dir_front,dir_back,dir_down,dir_down,

			dir_error,dir_error,dir_right,dir_right,dir_back,dir_front,

			dir_error,dir_error,dir_left,dir_left,dir_front,dir_back,

			dir_error,dir_error,dir_error,dir_error,dir_error,dir_error,

			dir_error,dir_error,dir_error,dir_error,dir_error,dir_error};

dir tilt(dir cur, dir tiltdir)

{

	int val = cur*num_dirs+tiltdir;

	return tiltarray[val];

}




void printdir(dir cur)

{

	switch (cur)

	{

		case dir_front:

			cout << "1";

			break;

		case dir_back:

			cout << "6";

			break;

		case dir_up:

			cout << "^";

			break;

		case dir_down:

			cout << "v";

			break;

		case dir_right:

			cout << ">";

			break;

		case dir_left:

			cout << "<";

			break;

		default:

			cout << " ";

			break;

	}


}


void drawgrid()

{

	for(int i = 0; i < GRIDSIZE*2+1; i++) cout << "_";

	cout << endl;

	for(int j = 0; j < GRIDSIZE; j++)

	{

		cout << "|";

		for(int i = 0; i < GRIDSIZE; i++)

		{

			printdir(facing[j*GRIDSIZE+i]);

			//printdir(move[j*GRIDSIZE+i]);


			if (i <= GRIDSIZE-2)

			{

				if ((move[j*GRIDSIZE+i]==dir_right) || (move[j*GRIDSIZE+i+1]==dir_left))

				{

					cout << "=";

				}

				else

				{

					cout << " ";

				}

			}


		}

		cout << "|" << endl;


		if (j <= GRIDSIZE-2)

		{

			cout << "|";

			for(int i = 0; i < GRIDSIZE; i++)

			{

				if ((move[j*GRIDSIZE+i]==dir_down) || (move[(j+1)*GRIDSIZE+i]==dir_up))

				{

					cout << "|";

				}

				else

				{

					cout << " ";

				}

				if (i < GRIDSIZE-1) cout << "X";

			}

			cout << "|" << endl;

		}

	}

	for(int i = 0; i < GRIDSIZE*2+1; i++) cout << "-";

	cout << endl;

}


int validmove(dir tiltdir, int verbose)

{

	if (((tiltdir==dir_up)&&(hist.back()<GRIDSIZE)) ||

   	 ((tiltdir==dir_down)&&(hist.back()>=(GRIDSIZE-1)*GRIDSIZE)) ||

   	 ((tiltdir==dir_right)&&(hist.back()%GRIDSIZE==GRIDSIZE-1)) ||

   	 ((tiltdir==dir_left)&&(hist.back()%GRIDSIZE==0)))

	{

		if (verbose) cout << "Invalid move: Boundary hit." << endl;

		return 0;

	}

	if (facing[hist.back()+displacement[tiltdir]] != dir_error)

	{

		if (verbose) cout << "Invalid move: Repeating a square." << endl;

		return 0;

	}

	if ((tilt(facing[hist.back()],tiltdir)==dir_front) && (hist.size() != GRIDSIZE*GRIDSIZE-1))

	{

		if (verbose) cout << "Invalid move: 1 would be facing up." << endl;

		return 0;

	}

	return 1;

}


int solved()

{

	if ((hist.size()==GRIDSIZE*GRIDSIZE) &&

		(facing[hist.back()] == dir_front))

		return 1;

	return 0;

}







int main(int argc, char *argv[])

{



	hist.push_back(0);


	for(int i = 0; i < GRIDSIZE*GRIDSIZE; i++)

	{

		facing[i] = dir_error;

		move[i] = dir_error;

	}

	facing[0] = dir_front;


	drawgrid();

	while (1)

	{

		int ch = getchar();

		dir tiltdir = dir_error;


		switch (ch)

		{

			case 'w'://up

				tiltdir = dir_up;

				break;

			case 's'://down

				tiltdir = dir_down;

				break;

			case 'd'://right

				tiltdir = dir_right;

				break;

			case 'a'://left

				tiltdir = dir_left;

				break;

			case ' '://undo

				tiltdir = dir_undo;

				break;

			case 'k'://solve it

				hist.clear();

				hist.push_back(0);

				for(int i = 0; i < GRIDSIZE*GRIDSIZE; i++)

				{

					facing[i] = dir_error;

					move[i] = dir_error;

				}

				facing[0] = dir_front;

				hist.reserve(GRIDSIZE*GRIDSIZE+1);

				while(hist.size() > 0)

				{

					//if (hist.size() > GRIDSIZE*(GRIDSIZE-1)+6)

					//{

					//	drawgrid();

					//	getchar();

					//}

					dir nextone = dir_error;

					switch(move[hist.back()])

					{

						case dir_error: nextone = dir_up; break;

						case dir_up: nextone = dir_down; break;

						case dir_down: nextone = dir_right; break;

						case dir_right: nextone = dir_left; break;

						case dir_left: nextone = dir_undo; break;

						default:

							cout << "Should never get here!!" << endl;

					}

					if (nextone == dir_undo)

					{

						if (hist.size() <= 1) break;

						facing[hist.back()] = dir_error;

						move[hist.back()] = dir_error;

						hist.pop_back();

						continue;

					}

					move[hist.back()] = nextone;

					if (validmove(nextone,0))

					{

						dir temp = tilt(facing[hist.back()],nextone);

						hist.push_back(hist.back()+displacement[nextone]);

						facing[hist.back()] = temp;

						move[hist.back()] = dir_error;

						if (solved())

						{

							cout << "Found one!" << endl;

							drawgrid();

						}

					}

				}

				cout << "Done!" << endl;

				break;

			default:

				break;

		}


		if (tiltdir == dir_error) continue;


		if (tiltdir == dir_undo)

		{

			if (hist.size() <= 1) continue;

			facing[hist.back()] = dir_error;

			hist.pop_back();

			move[hist.back()] = dir_error;

			drawgrid();

			continue;

		}



		if (validmove(tiltdir,1))

		{

			move[hist.back()] = tiltdir;

			dir temp = tilt(facing[hist.back()],tiltdir);

			hist.push_back(hist.back()+displacement[tiltdir]);

			facing[hist.back()] = temp;

		}


		drawgrid();

	}


}
So it seems there is only one other solution (ignoring reflections), and it ends at (2,5) or (5,2) depending on if it's reflected. So you can get it to end at (8,1), (1,8), (2,5), or (5,2). You could also change the beginning position to see what solutions that gives. It shouldn't take too long to run given that there are only 10 unique starting positions (ignoring reflections and rotations). Perhaps I'll give that a try too.
Found one!

_________________

|1 v=v=v=v=v=v=v|

||X|X X X X X X||

|v 6=< v=v=v >=6|

||X X|X|X X|X|X |

|6 6=< 6=< 6 >=6|

||X|X X X|X|X X||

|^=^ >=6=< ^=^=^|

| X X|X X X X X |

|v=v >=6=< v=v=v|

||X|X X X|X|X X||

|6 6=< 6=< 6 >=6|

||X X|X|X X|X|X |

|^ 6=< ^=^=^ >=6|

||X|X X X X X X||

|1 ^=^=^=^=^=^=^|

-----------------

Found one!

_________________

|1 v=v=v=v=v=v=v|

||X|X X X X X X||

|v 6 6=<=1 >=6 6|

||X|X|X X X|X|X||

|6 ^=^ 6=< > ^=^|

||X X X|X|X|X X |

|^=^=^=^ < >=6=<|

| X X X X|X X X||

|v=v=v=v < >=6=<|

||X X X|X|X|X X |

|6=< >=6 < > v=v|

| X|X|X X|X|X|X||

|6=< >=6=< >=6 6|

||X X X X X X X||

|^=^=^=^=^=^=^=^|

-----------------

Found one!

_________________

|1=>=6=< >=6 6=<|

| X X X|X|X|X|X||

|>=6=< < > ^=^ <|

||X X|X|X|X X X||

|> 6=< < > v=v <|

||X|X X|X|X|X|X||

|> ^ 6=< >=6 6 <|

||X|X|X X X X|X||

|> 1 ^=^=^=^=^ <|

||X X X X X X X||

|> v=v=v v=v=v <|

||X|X X|X|X X|X||

|> 6=< 6 6 >=6 <|

||X X|X|X|X|X X||

|>=6=< ^=^ >=6=<|

-----------------

Found one!

_________________

|1=>=6=< >=6=<=1|

| X X X|X|X X X |

|>=6 6=< >=6 6=<|

||X|X|X X X|X|X||

|> ^=^ v=v ^=^ <|

||X X X|X|X X X||

|> >=6 6 6 6=< <|

||X|X|X|X|X|X|X||

|> > ^=^ ^=^ < <|

||X|X X X X X|X||

|> >=6=< >=6=< <|

||X X X|X|X X X||

|> v=v < > v=v <|

||X|X|X|X|X|X|X||

|>=6 6=< >=6 6=<|

-----------------

Done!

0

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <memory.h>
#include <vector>


using namespace std;
#define GRIDSIZE 8

enum dir
{
dir_front = 0,
dir_back = 1,
dir_up = 2,
dir_down = 3,
dir_right = 4,
dir_left = 5,
num_dirs = 6,
dir_error = 7,
dir_undo = 8
};

dir facing;
dir move;
vector<int> hist;
int displacement = {0,0,-GRIDSIZE,GRIDSIZE,1,-1,0,0};

int startpos;
dir startdir;


dir tiltarray[] = {dir_error,dir_error,dir_up,dir_down,dir_right,dir_left,
dir_error,dir_error,dir_down,dir_up,dir_left,dir_right,
dir_error,dir_error,dir_back,dir_front,dir_up,dir_up,
dir_error,dir_error,dir_front,dir_back,dir_down,dir_down,
dir_error,dir_error,dir_right,dir_right,dir_back,dir_front,
dir_error,dir_error,dir_left,dir_left,dir_front,dir_back,
dir_error,dir_error,dir_error,dir_error,dir_error,dir_error,
dir_error,dir_error,dir_error,dir_error,dir_error,dir_error};
dir tilt(dir cur, dir tiltdir)
{
int val = cur*num_dirs+tiltdir;
return tiltarray;
}



void printdir(dir cur)
{
switch (cur)
{
case dir_front:
cout << "1";
break;
case dir_back:
cout << "6";
break;
case dir_up:
cout << "^";
break;
case dir_down:
cout << "v";
break;
case dir_right:
cout << ">";
break;
case dir_left:
cout << "<";
break;
default:
cout << " ";
break;
}

}

void drawgrid()
{
for(int i = 0; i < GRIDSIZE*2+1; i++) cout << "_";
cout << endl;
for(int j = 0; j < GRIDSIZE; j++)
{
cout << "|";
for(int i = 0; i < GRIDSIZE; i++)
{
printdir(facing);
//printdir(move);

if (i <= GRIDSIZE-2)
{
if ((move==dir_right) || (move==dir_left))
{
cout << "=";
}
else
{
cout << " ";
}
}

}
cout << "|" << endl;

if (j <= GRIDSIZE-2)
{
cout << "|";
for(int i = 0; i < GRIDSIZE; i++)
{
if ((move==dir_down) || (move==dir_up))
{
cout << "|";
}
else
{
cout << " ";
}
if (i < GRIDSIZE-1) cout << "X";
}
cout << "|" << endl;
}
}
for(int i = 0; i < GRIDSIZE*2+1; i++) cout << "-";
cout << endl;
}

int validmove(dir tiltdir, int verbose)
{
if (((tiltdir==dir_up)&&(hist.back()<GRIDSIZE)) ||
((tiltdir==dir_down)&&(hist.back()>=(GRIDSIZE-1)*GRIDSIZE)) ||
((tiltdir==dir_right)&&(hist.back()%GRIDSIZE==GRIDSIZE-1)) ||
((tiltdir==dir_left)&&(hist.back()%GRIDSIZE==0)))
{
if (verbose) cout << "Invalid move: Boundary hit." << endl;
return 0;
}
if (facing] != dir_error)
{
if (verbose) cout << "Invalid move: Repeating a square." << endl;
return 0;
}
if ((tilt(facing,tiltdir)==dir_front) && (hist.size() != GRIDSIZE*GRIDSIZE-1))
{
if (verbose) cout << "Invalid move: 1 would be facing up." << endl;
return 0;
}
return 1;
}

int solved()
{
if ((hist.size()==GRIDSIZE*GRIDSIZE) &&
(facing == dir_front))
return 1;
return 0;
}

int validmovecircuit(dir tiltdir)
{
if (((tiltdir==dir_up)&&(hist.back()<GRIDSIZE)) ||
((tiltdir==dir_down)&&(hist.back()>=(GRIDSIZE-1)*GRIDSIZE)) ||
((tiltdir==dir_right)&&(hist.back()%GRIDSIZE==GRIDSIZE-1)) ||
((tiltdir==dir_left)&&(hist.back()%GRIDSIZE==0)))
return 0;
if (facing] != dir_error)
return 0;
if (tilt(facing,tiltdir)==dir_front)
return 0;
return 1;
}

int solvedcircuit(dir tiltdir)
{
dir nextdir = tilt(facing,tiltdir);
int nextpos = hist.back()+displacement;
if ((hist.size()==GRIDSIZE*GRIDSIZE) &&
(nextdir == startdir) &&
(nextpos == startpos))
return 1;
return 0;
}






int main(int argc, char *argv[])
{


hist.push_back(0);

for(int i = 0; i < GRIDSIZE*GRIDSIZE; i++)
{
facing = dir_error;
move = dir_error;
}
facing = dir_front;

drawgrid();
int ch = 0;
while (1)
{
if (ch != 10) cout << "Enter command (wasd,k-solve,o-circuit,' '-undo): ";
ch = getchar();
dir tiltdir = dir_error;

switch (ch)
{
case 'w'://up
tiltdir = dir_up;
break;
case 's'://down
tiltdir = dir_down;
break;
case 'd'://right
tiltdir = dir_right;
break;
case 'a'://left
tiltdir = dir_left;
break;
case ' '://undo
tiltdir = dir_undo;
break;
case 'o'://circuit
{
int xpos,ypos,dirtemp;
cout << "X (0-" << (GRIDSIZE-1) << "): ";
cin >> xpos;
cout << "Y (0-" << (GRIDSIZE-1) << "): ";
cin >> ypos;
cout << "dir (0-f,1-b,2-u,3-d,4-r,5-l):";
cin >> dirtemp;
startdir = (dir) dirtemp;
startpos = ypos*GRIDSIZE+xpos;
hist.clear();
hist.push_back(startpos);
for(int i = 0; i < GRIDSIZE*GRIDSIZE; i++)
{
facing = dir_error;
move = dir_error;
}
facing = startdir;
hist.reserve(GRIDSIZE*GRIDSIZE+1);
while(hist.size() > 0)
{
dir nextone = dir_error;
switch(move)
{
case dir_error: nextone = dir_up; break;
case dir_up: nextone = dir_down; break;
case dir_down: nextone = dir_right; break;
case dir_right: nextone = dir_left; break;
case dir_left: nextone = dir_undo; break;
default:
cout << "Should never get here!!" << endl;
}
if (nextone == dir_undo)
{
if (hist.size() <= 1) break;
facing = dir_error;
move = dir_error;
hist.pop_back();
continue;
}
move = nextone;
if (validmovecircuit(nextone))
{
dir temp = tilt(facing,nextone);
hist.push_back(hist.back()+displacement);
facing = temp;
move = dir_error;
if (hist.size()==GRIDSIZE*GRIDSIZE)
{
dir dirs = {dir_up,dir_down,dir_right,dir_left,dir_undo};
for(int i = 0; i < 4; i++)
{
if (solvedcircuit(dirs))
{
move = dirs;
cout << "Found one!" << endl;
drawgrid();
move = dir_error;
}
}
}
}
}
cout << "Done!" << endl;
break;
}
case 'k'://solve it
{
int xpos,ypos;
cout << "X (0-" << (GRIDSIZE-1) << "): ";
cin >> xpos;
cout << "Y (0-" << (GRIDSIZE-1) << "): ";
cin >> ypos;
startpos = ypos*GRIDSIZE+xpos;
hist.clear();
hist.push_back(startpos);
for(int i = 0; i < GRIDSIZE*GRIDSIZE; i++)
{
facing = dir_error;
move = dir_error;
}
facing = dir_front;
hist.reserve(GRIDSIZE*GRIDSIZE+1);
while(hist.size() > 0)
{
dir nextone = dir_error;
switch(move)
{
case dir_error: nextone = dir_up; break;
case dir_up: nextone = dir_down; break;
case dir_down: nextone = dir_right; break;
case dir_right: nextone = dir_left; break;
case dir_left: nextone = dir_undo; break;
default:
cout << "Should never get here!!" << endl;
}
if (nextone == dir_undo)
{
if (hist.size() <= 1) break;
facing = dir_error;
move = dir_error;
hist.pop_back();
continue;
}
move = nextone;
if (validmove(nextone,0))
{
dir temp = tilt(facing,nextone);
hist.push_back(hist.back()+displacement);
facing = temp;
move = dir_error;
if (solved())
{
cout << "Found one!" << endl;
drawgrid();
}
}
}
cout << "Done!" << endl;
break;
}
default:
break;
}

if (tiltdir == dir_error) continue;

if (tiltdir == dir_undo)
{
if (hist.size() <= 1) continue;
facing = dir_error;
hist.pop_back();
move = dir_error;
drawgrid();
continue;
}


if (validmove(tiltdir,1))
{
move = tiltdir;
dir temp = tilt(facing,tiltdir);
hist.push_back(hist.back()+displacement);
facing = temp;
}

drawgrid();
}

}

I will put the commands used to find them in the title of the spoiler (or just listed if nothing was found with those commands).

I'll also remove solutions that are reflections and/or rotations of other solutions when found during the same command, but I'll leave the duplicates found with different commands (but they'll be in different spoiler boxes anyway).

Found one!
_________________
|1=>=6=< >=6 6=<|
| X X X|X|X|X|X||
|>=6=< < > ^=^ <|
||X X|X|X|X X X||
|> 6=< < > v=v <|
||X|X X|X|X|X|X||
|> ^ 6=< >=6 6 <|
||X|X|X X X X|X||
|> 1 ^=^=^=^=^ <|
||X X X X X X X||
|> v=v=v v=v=v <|
||X|X X|X|X X|X||
|> 6=< 6 6 >=6 <|
||X X|X|X|X|X X||
|>=6=< ^=^ >=6=<|
-----------------
Found one!
_________________
|1=>=6=< >=6=<=1|
| X X X|X|X X X |
|>=6 6=< >=6 6=<|
||X|X|X X X|X|X||
|> ^=^ v=v ^=^ <|
||X X X|X|X X X||
|> >=6 6 6 6=< <|
||X|X|X|X|X|X|X||
|> > ^=^ ^=^ < <|
||X|X X X X X|X||
|> >=6=< >=6=< <|
||X X X|X|X X X||
|> v=v < > v=v <|
||X|X|X|X|X|X|X||
|>=6 6=< >=6 6=<|
-----------------
Done!
k,1,0: None for a 1 at (1,0).
Found one!
_________________
|v=v 1=> v=v=v=v|
||X|X X|X|X X X||
|6 6=< >=6 >=6 6|
||X X|X X X|X|X||
|^ 6=< 6=< > ^=^|
||X|X X|X|X|X X |
|1 ^=^=^ < >=6=<|
| X X X X|X X X||
|v=v=v=v < >=6=<|
||X X X|X|X|X X |
|6=< >=6 < > v=v|
| X|X|X X|X|X|X||
|6=< >=6=< >=6 6|
||X X X X X X X||
|^=^=^=^=^=^=^=^|
-----------------
Found one!
_________________
|>=6 1=>=6 >=6=<|
||X|X X X|X|X X||
|> ^=^=^=^ >=6 <|
||X X X X X X|X||
|> >=6=< ^=^=^ <|
||X|X X|X|X X X||
|> > 6=< 1 6=< <|
||X|X|X X X|X|X||
|> > ^=^=^=^ < <|
||X|X X X X X|X||
|> >=6=< >=6=< <|
||X X X|X|X X X||
|> v=v < > v=v <|
||X|X|X|X|X|X|X||
|>=6 6=< >=6 6=<|
-----------------
Done!
Found one!
_________________
|>=6=< 1=>=6 6=<|
||X X|X X X|X|X||
|> 6=< 6=< ^=^ <|
||X|X X|X|X X X||
|> ^=^=^ < >=6=<|
||X X X X|X|X X |
|>=6=< 6=< >=6 1|
| X X|X|X X X|X||
|>=6=< ^=^=^=^ v|
||X X X X X X X||
|> v=v=v v=v >=6|
||X|X X|X|X|X|X |
|> 6=< 6 6 6 >=6|
||X X|X|X|X|X X||
|>=6=< ^=^ ^=^=^|
-----------------
Found one!
_________________
|>=6=< 1=>=6 6=<|
||X X|X X X|X|X||
|> 6=< 6=< ^=^ <|
||X|X X|X|X X X||
|> ^=^=^ < >=6=<|
||X X X X|X|X X |
|>=6 6=< < >=6=<|
| X|X|X|X|X X X||
|1 ^=^ < < >=6=<|
||X X X|X|X|X X |
|v >=6=< < > v=v|
||X|X X X|X|X|X||
|6 >=6 6=< >=6 6|
||X X|X|X X X X||
|^=^=^ ^=^=^=^=^|
-----------------
Found one!
_________________
|>=6=< 1=>=6 6=<|
||X X|X X X|X|X||
|> 6=< 6=< ^=^ <|
||X|X X|X|X X X||
|> ^=^=^ < >=6=<|
||X X X X|X|X X |
|>=6=<=1 < >=6=<|
| X X X X|X X X||
|v=v=v=v < >=6=<|
||X X X|X|X|X X |
|6=< >=6 < > v=v|
| X|X|X X|X|X|X||
|6=< >=6=< >=6 6|
||X X X X X X X||
|^=^=^=^=^=^=^=^|
-----------------
Found one!
_________________
|>=6=<=1 1=>=6=<|
||X X X X X X X||
|> v=v=v=v=v=v <|
||X|X X X X X|X||
|> 6 6=< >=6 6 <|
||X|X|X|X|X|X|X||
|> ^=^ < > ^=^ <|
||X X X|X|X X X||
|> >=6=< > >=6=<|
||X|X X X|X|X X |
|> >=6=< > >=6=<|
||X X X|X|X X X||
|> v=v < > v=v <|
||X|X|X|X|X|X|X||
|>=6 6=< >=6 6=<|
-----------------
Found one!
_________________
|>=6=<=1 1=>=6=<|
||X X X X X X X||
|> v=v=v=v=v=v <|
||X|X X X X X|X||
|> 6 6=< >=6 6 <|
||X|X|X|X|X|X|X||
|> ^=^ < > ^=^ <|
||X X X|X|X X X||
|> >=6=< >=6=< <|
||X|X X X X X|X||
|> >=6=< >=6=< <|
||X X X|X|X X X||
|> v=v < > v=v <|
||X|X|X|X|X|X|X||
|>=6 6=< >=6 6=<|
-----------------
Found one!
_________________
|>=6=<=1 1=>=6=<|
||X X X X X X X||
|> v=v=v=v=v=v <|
||X|X X X X X|X||
|> 6 6=< >=6 6 <|
||X|X|X|X|X|X|X||
|> ^=^ < > ^=^ <|
||X X X|X|X X X||
|>=6=< < > >=6=<|
| X X|X|X|X|X X |
|>=6=< < > >=6=<|
||X X X|X|X X X||
|> v=v < > v=v <|
||X|X|X|X|X|X|X||
|>=6 6=< >=6 6=<|
-----------------
Found one!
_________________
|>=6=<=1 1=>=6=<|
||X X X X X X X||
|> v=v=v v=v=v <|
||X|X X|X|X X|X||
|>=6 >=6 6=< 6=<|
| X X|X X X|X X |
|>=6 >=6 6=< 6=<|
||X|X X|X|X X|X||
|> ^=^=^ ^=^=^ <|
||X X X X X X X||
|> v=v=v v=v=v <|
||X|X X|X|X X|X||
|> 6=< 6 6 >=6 <|
||X X|X|X|X|X X||
|>=6=< ^=^ >=6=<|
-----------------
Found one!
_________________
|>=6=<=1 >=6 6=<|
||X X X X|X|X|X||
|>=6 6=< > ^=^ <|
| X|X|X|X|X X X||
|1 ^=^ < > v=v <|
||X X X|X|X|X|X||
|v=v 6=< >=6 6 <|
| X|X|X X X X|X||
|>=6 ^=^=^=^=^ <|
||X X X X X X X||
|> v=v=v v=v=v <|
||X|X X|X|X X|X||
|> 6=< 6 6 >=6 <|
||X X|X|X|X|X X||
|>=6=< ^=^ >=6=<|
-----------------
Found one!
_________________
|>=6=<=1 >=6 6=<|
||X X X X|X|X|X||
|>=6=< 1 > ^=^ <|
| X X|X|X|X X X||
|>=6=< v > v=v <|
||X X X|X|X|X|X||
|>=6=< 6 >=6 6 <|
| X X|X|X X X|X||
|>=6=< ^=^=^=^ <|
||X X X X X X X||
|> v=v=v v=v=v <|
||X|X X|X|X X|X||
|> 6=< 6 6 >=6 <|
||X X|X|X|X|X X||
|>=6=< ^=^ >=6=<|
-----------------
Done!
Found one!
_________________
|>=6=< v=v=v=v=v|
||X X|X|X X X X||
|> 1 < 6=< >=6 6|
||X|X|X X|X|X|X||
|> v < 1 < > ^=^|
||X|X|X|X|X|X X |
|> 6=< v < >=6=<|
||X X X|X|X X X||
|>=6=< 6=< >=6=<|
| X X|X X X|X X |
|v=v < v=v > v=v|
||X|X|X|X|X|X|X||
|6 6=< 6 6 >=6 6|
||X X X|X|X X X||
|^=^=^=^ ^=^=^=^|
-----------------
Done!
Found one!
_________________
|v=v=v=v=v=v=v=v|
||X X X X X X X||
|6=< 1=>=6=< >=6|
| X|X X X X|X|X |
|6=< 6=< 6=< >=6|
||X X|X|X|X X X||
|^=^=^ < ^=^=^=^|
| X X X|X X X X |
|v=v=v < v=v=v=v|
||X X|X|X|X X X||
|6=< 6=< 6=< >=6|
| X|X X X X|X|X |
|6=< 1=>=6=< >=6|
||X X X X X X X||
|^=^=^=^=^=^=^=^|
-----------------
Found one!
_________________
|v=v=v=v v=v=v=v|
||X X X|X|X X X||
|6=<=1 6 6 >=6 6|
| X X X|X|X|X|X||
|>=6=< ^=^ > ^=^|
||X X|X X X|X X |
|> 6=< 6=< >=6=<|
||X|X X|X|X X X||
|> ^=^=^ < >=6=<|
||X X X X|X|X X |
|> 1 v=v < > v=v|
||X|X|X|X|X|X|X||
|> v 6 6=< >=6 6|
||X|X|X X X X X||
|>=6 ^=^=^=^=^=^|
-----------------
Found one!
_________________
|v=v=v=v=v=v=v=v|
||X X X X X X X||
|6=<=1 v=v=v >=6|
| X X X|X X|X|X |
|>=6=< 6=< 6 >=6|
||X X|X X|X|X X||
|> 6=< 6=< ^=^=^|
||X|X X|X X X X |
|> ^=^=^ 1=>=6=<|
||X X X X X X X||
|> v=v=v v=v=v <|
||X|X X|X|X X|X||
|> 6=< 6 6 >=6 <|
||X X|X|X|X|X X||
|>=6=< ^=^ >=6=<|
-----------------
Done!
Found one!
_________________
|>=6=<=1 >=6 6=<|
||X X X X|X|X|X||
|>=6=< 1 > ^=^ <|
| X X|X|X|X X X||
|>=6=< v > v=v <|
||X X X|X|X|X|X||
|>=6=< 6 >=6 6 <|
| X X|X|X X X|X||
|>=6=< ^=^=^=^ <|
||X X X X X X X||
|> v=v=v v=v=v <|
||X|X X|X|X X|X||
|> 6=< 6 6 >=6 <|
||X X|X|X|X|X X||
|>=6=< ^=^ >=6=<|
-----------------
Found one!
_________________
|v=v=v=v=v=v=v 1|
||X X X X X X|X||
|6 6=< 1=>=6 6 v|
||X|X|X X X|X|X||
|^=^ < >=6 ^=^ 6|
| X X|X|X|X X X||
|>=6=< > ^=^=^=^|
||X X X|X X X X |
|>=6=< > v=v=v=v|
| X X|X|X|X X X||
|v=v < > 6=< >=6|
||X|X|X|X X|X|X |
|6 6=< >=6=< >=6|
||X X X X X X X||
|^=^=^=^=^=^=^=^|
-----------------
Found one!
_________________
|v=v=v=v=v >=6=<|
||X X X X|X|X X||
|6 6=<=1 6 >=6 <|
||X|X X X|X X|X||
|^=^ v=v ^=^=^ <|
| X X|X|X X X X||
|>=6 6 6 1=>=6 <|
||X|X|X|X X X|X||
|> ^=^ ^=^=^=^ <|
||X X X X X X X||
|> v=v=v v=v=v <|
||X|X X|X|X X|X||
|> 6=< 6 6 >=6 <|
||X X|X|X|X|X X||
|>=6=< ^=^ >=6=<|
-----------------
Done!
k,2,2: None for a 1 at (2,2).
Found one!
_________________
|>=6=< v=v=v=v=v|
||X X|X|X X X X||
|> 1 < 6=< >=6 6|
||X|X|X X|X|X|X||
|> v < 1 < > ^=^|
||X|X|X|X|X|X X |
|> 6=< v < >=6=<|
||X X X|X|X X X||
|>=6=< 6=< >=6=<|
| X X|X X X|X X |
|v=v < v=v > v=v|
||X|X|X|X|X|X|X||
|6 6=< 6 6 >=6 6|
||X X X|X|X X X||
|^=^=^=^ ^=^=^=^|
-----------------
Done!
Found one!
_________________
|v=v=v=v >=6 6=<|
||X X X|X|X|X|X||
|6 6=< 6 > ^=^ <|
||X|X|X|X|X X X||
|^=^ < ^ > v=v <|
| X X|X|X|X|X|X||
|1 6=< 1 >=6 6 <|
||X|X X X X X|X||
|v ^=^=^=^=^=^ <|
||X X X X X X X||
|6=< v=v v=v=v <|
| X|X|X|X|X X|X||
|6=< 6 6 6 >=6 <|
||X X|X|X|X|X X||
|^=^=^ ^=^ >=6=<|
-----------------
Found one!
_________________
|v=v=v=v >=6 6=<|
||X X X|X|X|X|X||
|6 6=< 6 > ^=^ <|
||X|X|X|X|X X X||
|^=^ < ^ >=6=< <|
| X X|X|X X X|X||
|>=6=< 1 >=6=< <|
||X X X X|X X X||
|>=6=< 1=> >=6=<|
| X X|X X X|X X |
|v=v < v=v > v=v|
||X|X|X|X|X|X|X||
|6 6=< 6 6 >=6 6|
||X X X|X|X X X||
|^=^=^=^ ^=^=^=^|
-----------------
Found one!
_________________
|v=v=v=v >=6 6=<|
||X X X|X|X|X|X||
|6 6=< 6 > ^=^ <|
||X|X|X|X|X X X||
|^=^ < ^ > >=6=<|
| X X|X|X|X|X X |
|>=6=< 1 > >=6=<|
||X X X X|X X X||
|>=6=< 1=> >=6=<|
| X X|X X X|X X |
|v=v < v=v > v=v|
||X|X|X|X|X|X|X||
|6 6=< 6 6 >=6 6|
||X X X|X|X X X||
|^=^=^=^ ^=^=^=^|
-----------------
Found one!
_________________
|v=v=v=v=v=v=v=v|
||X X X X X X X||
|6 6=< 6=< >=6 6|
||X|X|X|X|X|X|X||
|^=^ < ^ < > ^=^|
| X X|X|X|X|X X |
|>=6=< 1 < >=6=<|
||X X X X|X X X||
|> 1 >=6=< >=6=<|
||X|X|X X X|X X |
|> v >=6=< > v=v|
||X|X X X|X|X|X||
|> 6=< 6=< >=6 6|
||X X|X|X X X X||
|>=6=< ^=^=^=^=^|
-----------------
Found one!
_________________
|v=v=v=v=v=v=v=v|
||X X X X X X X||
|6 6=< v=v=v >=6|
||X|X|X|X X|X|X |
|^=^ < 6=< 6 >=6|
| X X|X X|X|X X||
|6=< <=1 < ^=^=^|
||X|X X X|X X X |
|^ < v=v < v=v=v|
||X|X|X|X|X|X X||
|1 < 6 6=< 6 >=6|
| X|X|X X X|X|X |
|6=< ^=^=^=^ >=6|
||X X X X X X X||
|^=^=^=^=^=^=^=^|
-----------------
Found one!
_________________
|>=6=< v=v >=6=<|
||X X|X|X|X|X X||
|> 6=< 6 6 >=6 <|
||X|X X|X|X X|X||
|> ^=^=^ ^=^=^ <|
||X X X X X X X||
|>=6=<=1 v=v=v <|
| X X X X|X X|X||
|v=v=v >=6 >=6 <|
||X X|X|X X|X X||
|6=< 6 >=6 >=6=<|
| X|X|X X|X X X |
|6=< ^=^=^ 1=>=6|
||X X X X X X X||
|^=^=^=^=^=^=^=^|
-----------------
Done!

Well, that was interesting. There were quite a few solutions in general, and a few spots with none.

Note: All reflections are shown twice by the code due to two directions to start moving.

o,0,0,0: None for a 1 at (0,0).
o,1,0,0: None for a 1 at (1,0).
o,2,0,0: None for a 1 at (2,0).
o,3,0,0: None for a 1 at (3,0).
o,1,1,0: None for a 1 at (1,1).
Two of them.Found one!
_________________
|v=v=v=v=v >=6=<|
||X X X X|X|X X||
|6=<=1=> 6 >=6 <|
| X X X|X|X X|X||
|>=6=< > ^=^=^ <|
||X X|X|X X X X||
|> 6=< >=6 >=6=<|
||X|X X X|X|X X |
|> ^=^=^=^ >=6=<|
||X X X X X X X||
|> v=v=v v=v=v <|
||X|X X|X|X X|X||
|> 6=< 6 6 >=6 <|
||X X|X|X|X|X X||
|>=6=< ^=^ >=6=<|
-----------------
Found one!
_________________
|v=v=v=v=v=v=v=v|
||X X X X X X X||
|6=<=1 >=6=< >=6|
| X X|X|X X|X|X |
|v=v=v > 6=< >=6|
||X X X|X|X X X||
|6 6=< > ^=^=^=^|
||X|X|X|X X X X |
|^=^ < > v=v=v=v|
| X X|X|X|X X X||
|v=v < > 6=< >=6|
||X|X|X|X X|X|X |
|6 6=< >=6=< >=6|
||X X X X X X X||
|^=^=^=^=^=^=^=^|
-----------------
Done!
o,3,1,0: None for a 1 at (3,1).
o,2,2,0: None for a 1 at (2,2).
o,3,2,0: None for a 1 at (3,2).
o,3,3,0: None for a 1 at (3,3).
It turns out that there is only one circuit (unique ignoring reflections and rotations) without any 1's. (found setting die in top left corner to point right (easy to show it cannot be anything but right or down and still complete a circuit)).
_________________
|>=6=< v=v >=6=<|
||X X|X|X|X|X X||
|> 6=< 6 6 >=6 <|
||X|X X|X|X X|X||
|> ^=^=^ ^=^=^ <|
||X X X X X X X||
|> v=v=v=v=v=v <|
||X|X X X X X|X||
|> 6 6=< >=6 6 <|
||X|X|X|X|X|X|X||
|> ^=^ < > ^=^ <|
||X X X|X|X X X||
|> v=v < > v=v <|
||X|X|X|X|X|X|X||
|>=6 6=< >=6 6=<|
-----------------
So there are 2 solutions (unique ignoring reflections and rotations) for a circuit containing one 1, and they both happen with the 1 a knights move from a corner.
And there exists a single circuit (unique ignoring reflections and rotations) without a 1.

I was thinking there would be more.
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.