How to resolve the algorithm Solve the no connection puzzle step by step in the 11l 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 11l 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 11l programming language
Source code in the 11l programming language
V connections = [(0, 2), (0, 3), (0, 4),
(1, 3), (1, 4), (1, 5),
(6, 2), (6, 3), (6, 4),
(7, 3), (7, 4), (7, 5),
(2, 3), (3, 4), (4, 5)]
F ok(conn, perm)
R abs(perm[conn[0]] - perm[conn[1]]) != 1
F solve()
[[Int]] r
V perm = Array(1..8)
L
I all(:connections.map(conn -> ok(conn, @perm)))
r [+]= copy(perm)
I !perm.next_permutation()
L.break
R r
V solutions = solve()
print(‘A, B, C, D, E, F, G, H = ’solutions[0].join(‘, ’))
You may also check:How to resolve the algorithm Probabilistic choice step by step in the C++ programming language
You may also check:How to resolve the algorithm Non-decimal radices/Input step by step in the J programming language
You may also check:How to resolve the algorithm Median filter step by step in the D programming language
You may also check:How to resolve the algorithm CSV to HTML translation step by step in the CoffeeScript programming language
You may also check:How to resolve the algorithm Terminal control/Ringing the terminal bell step by step in the Batch File programming language