How to resolve the algorithm Solve the no connection puzzle step by step in the APL programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Solve the no connection puzzle step by step in the APL programming language

Table of Contents

Problem Statement

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

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

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

Produce and show here   one   solution to the puzzle.

No Connection Puzzle (youtube).

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Solve the no connection puzzle step by step in the APL programming language

Source code in the apl programming language

     perms{
     ⍝∇ 20100513/20140818 ra⌈ --()--
        1=:[ '']
       {0:  ([1]),(1) ~[1]}()¨1+()¯1+!
   }

solution{
    links  (3 4 5) (4 5 6) (1 4 7) (1 2 3 5 7 8) (1 2 4 6 7 8) (2 5 8) (3 4 5) (4 5 6) ⍝ node i connects with nodes i⊃links
    tries8 perms 8
    fails{1{1¯1 0 1}¨|-¨{[]}¨}
  ⍝    ⍴⍸~tries fails ⍤1⊢links
  ⍝ 16
   solns~tries fails 1links
   tries[''solns;]
   }


  

You may also check:How to resolve the algorithm Convex hull step by step in the Action! programming language
You may also check:How to resolve the algorithm Write language name in 3D ASCII step by step in the Erlang programming language
You may also check:How to resolve the algorithm Command-line arguments step by step in the Jsish programming language
You may also check:How to resolve the algorithm 99 bottles of beer step by step in the gnuplot programming language
You may also check:How to resolve the algorithm Classes step by step in the Clojure programming language