How to resolve the algorithm Solve a Holy Knight's tour step by step in the Elixir programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Solve a Holy Knight's tour step by step in the Elixir programming language

Table of Contents

Problem Statement

Chess coaches have been known to inflict a kind of torture on beginners by taking a chess board, placing pennies on some squares and requiring that a Knight's tour be constructed that avoids the squares with pennies. This kind of knight's tour puzzle is similar to   Hidato. The present task is to produce a solution to such problems. At least demonstrate your program by solving the following:

Note that the zeros represent the available squares, not the pennies. Extra credit is available for other interesting examples.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Solve a Holy Knight's tour step by step in the Elixir programming language

Source code in the elixir programming language

# require HLPsolver
 
adjacent = [{-1,-2},{-2,-1},{-2,1},{-1,2},{1,2},{2,1},{2,-1},{1,-2}]
 
"""
. . 0 0 0
. . 0 . 0 0
. 0 0 0 0 0 0 0
0 0 0 . . 0 . 0
0 . 0 . . 0 0 0
1 0 0 0 0 0 0
. . 0 0 . 0
. . . 0 0 0
"""
|> HLPsolver.solve(adjacent)

"""
 _ _ _ _ _ 1 _ 0          
 _ _ _ _ _ 0 _ 0          
 _ _ _ _ 0 0 0 0 0        
 _ _ _ _ _ 0 0 0          
 _ _ 0 _ _ 0 _ 0 _ _ 0    
 0 0 0 0 0 _ _ _ 0 0 0 0 0
 _ _ 0 0 _ _ _ _ _ 0 0    
 0 0 0 0 0 _ _ _ 0 0 0 0 0
 _ _ 0 _ _ 0 _ 0 _ _ 0    
 _ _ _ _ _ 0 0 0          
 _ _ _ _ 0 0 0 0 0        
 _ _ _ _ _ 0 _ 0          
 _ _ _ _ _ 0 _ 0          
"""
|> HLPsolver.solve(adjacent)


  

You may also check:How to resolve the algorithm Random number generator (included) step by step in the Phix programming language
You may also check:How to resolve the algorithm Levenshtein distance step by step in the Raku programming language
You may also check:How to resolve the algorithm Paraffins step by step in the Ruby programming language
You may also check:How to resolve the algorithm Untouchable numbers step by step in the F# programming language
You may also check:How to resolve the algorithm Product of min and max prime factors step by step in the FreeBASIC programming language