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).




Red ["Solve the no connection puzzle"]
 
points: [a b c d e f g h]
	; 'links' series will be scanned by pairs: [a c], [a d] etc.
links: [a c a d a e b d b e b f c d c g d e d g d h e f e g e h f h]
allpegs: [1 2 3 4 5 6 7 8]
 
	; check if two points are connected (then game is lost) i.e.
	; both are have a value (not zero) and absolute difference is 1
connected: func [x y] [all [
	x * y <> 0
	1 = absolute (x - y)
]]
	; a list of points is valid if no connexion is found
isvalid: function [pegs [block!]] [
	; assign pegs values to points, or 0 for remaining points
	set points append/dup copy pegs 0 8
	foreach [x y] links [if connected get x get y [return false]]
	true
]
	; recursively build a list of up to 8 valid points 
check: function [pegs [block!]] [
	if isvalid pegs [
		rest: difference allpegs pegs
		either empty? rest [
			print rejoin ["Here is a solution: " pegs] 
			halt ; comment this line to get all solutions
		][
			foreach peg rest [check append copy pegs peg]
		]	
	]
]
	; start with and empty list
check []
 