You are given a box with eight holes labelled   A-to-H,   connected by fifteen straight lines in the pattern as shown below:

             A   B
            /│\ /│\
           / │ X │ \
          /  │/ \│  \
         C───D───E───F
          \  │\ /│  /
           \ │ X │ /
            \│/ \│/
             G   H

You are also given eight pegs numbered   1-to-8.



Objective

Place the eight pegs in the holes so that the (absolute) difference between any two numbers connected by any line is greater than one.



Example

In this attempt:

             4   7
            /│\ /│\
           / │ X │ \
          /  │/ \│  \
         8───1───6───2
          \  │\ /│  /
           \ │ X │ /
            \│/ \│/
             3   5

Note that   7   and   6   are connected and have a difference of   1,   so it is   not   a solution.



Task
Produce and show here   one   solution to the puzzle.



Related tasks

   A* search algorithm
   Solve a Holy Knight's tour
   Knight's tour
   N-queens problem
   Solve a Hidato puzzle
   Solve a Holy Knight's tour
   Solve a Hopido puzzle
   Solve a Numbrix puzzle
   4-rings or 4-squares puzzle


See also
No Connection Puzzle (youtube).




include c:\cxpl\codes;
 
int     Hole, Max, I;
char    Box(8), Str;
def     A, B, C, D, E, F, G, H;
[for Hole:= 0 to 7 do Box(Hole):= Hole+1;
Max:= 7;
while   abs(Box(D)-Box(A)) < 2  or  abs(Box(D)-Box(C)) < 2  or
        abs(Box(D)-Box(G)) < 2  or  abs(Box(D)-Box(E)) < 2  or
        abs(Box(A)-Box(C)) < 2  or  abs(Box(C)-Box(G)) < 2  or
        abs(Box(G)-Box(E)) < 2  or  abs(Box(E)-Box(A)) < 2  or
        abs(Box(E)-Box(B)) < 2  or  abs(Box(E)-Box(H)) < 2  or
        abs(Box(E)-Box(F)) < 2  or  abs(Box(B)-Box(D)) < 2  or
        abs(Box(D)-Box(H)) < 2  or  abs(Box(H)-Box(F)) < 2  or
        abs(Box(F)-Box(B)) < 2  do
           loop [I:= Box(0);                    \next permutation
                for Hole:= 0 to Max-1 do Box(Hole):= Box(Hole+1);
                Box(Max):= I;
                if I # Max+1 then [Max:= 7;  quit]
                else Max:= Max-1];
Str:= "
    #   #
   /|\ /|\
  / | X | \
 /  |/ \|  \
# - # - # - #
 \  |\ /|  /
  \ | X | /
   \|/ \|/
    #   #
";
Hole:= 0;  I:= 0;
repeat  if Str(I)=^# then [Str(I):= Box(Hole)+^0;  Hole:= Hole+1];
        I:= I+1;
until   Hole = 8;
Text(0, Str);
]