Problem 47478. Slitherlink V: Assert/Evolve/Check (large)
This challenge is to solve Slitherlink pencil puzzles. An essential starter guide is Slitherlink Techniques. An s matrix with values from 0:5 is provided. An s of 5 means this locations edges are not provided and may be from 0:3. The player will be given the s, c, and initial p matrices. The c matrix is clarified for the creation of the solution path of nodes as given in c. The p matrix is a [numel,numel] matrix of c indices where p(x,y)=1 is a possible node connection. p(1,2)=1 as well as example's p(1,5)=1. Additional details of p are provided in the function template. Function template also includes visualization code.
This Slitherlink V: Assert/Evolve/Check(large size) is for the cases where s is not solved using only the Gimmes from Slitherlink Starting Techniques with a single Evolving and Recursion due to time and depth issues. Cases of Trivial, Gimmes, and single Evolve should be solved prior to invoking the Assert/Evolve/Check/Update method. The advanced solving techniques on the web are weak and complicated. The simple method is not to immediately invoke recursion due to the sparseness of data leading to too many false options. Ther actual simple method is to use Try/Catch by asserting segments as Black/Red and then checking if the layout using a robust Evolve creates an invalid state. If the state became invalid when asserting a single segment as Black then it must be Red with the same being true of Red assertion being invalid must mean the segment is Black. If an Evolve is invalid then Assert the right Bar type and perform an evolve to update the board. The two large test cases are from Games World of Puzzles October 2020. I was completely hopeless for the large puzzles. This set of five Cody Challenges is the result of five days banging my keyboard to solve Slitherlink.
Input: s, matrix of edge counts of the unique solution path; (c,p,bsegs,emap,pmap) are provided but not required
Output: sv, a vector of path nodes where sv(1)=sv(end). These nodes correspond to values in the c matrix example.
Example:
%[1 5 9 13 17 % c matrix [3 1 1 2; % s matrix [1 2 6 7 8 12 16 20 19 18 17 13 9 5 1] % sv
% 2 6 10 14 18 %path nodes 2 1 0 1; %qty edges % sv matrix is vector of nodes generating the
% 3 7 11 15 19 % corners 1 2 1 2] %adjacent % Red Line path
% 4 8 12 16 20] %to path
Related Challenges:![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPEAAAB/CAIAAACxE7P2AAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAB3RJTUUH5AsMABUVJm9/YgAAACR0RVh0U29mdHdhcmUATUF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slitherlink IV: Recursive(medium size)
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers2
Suggested Problems
-
Create a function handle that reverses the input arguments of another function handle
149 Solvers
-
Back to basics 9 - Indexed References
439 Solvers
-
Return the first and last characters of a character array
9488 Solvers
-
334 Solvers
-
5946 Solvers
More from this Author308
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!