Suppose you're given a 1D maze in an array of chars called 'maze'. The variable ‘size' contains the number of chars in t

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Suppose you're given a 1D maze in an array of chars called 'maze'. The variable ‘size' contains the number of chars in t

Post by answerhappygod »

Suppose You Re Given A 1d Maze In An Array Of Chars Called Maze The Variable Size Contains The Number Of Chars In T 1
Suppose You Re Given A 1d Maze In An Array Of Chars Called Maze The Variable Size Contains The Number Of Chars In T 1 (164.61 KiB) Viewed 69 times
}
Suppose you're given a 1D maze in an array of chars called 'maze'. The variable ‘size' contains the number of chars in the array. You can move left or right one char. The char 'X' represents impassible space. Any other char can be passed through either forward or backward). The char 'S' is the starting point and 'F' is the finish point. Example: X S F X X This puzzle is fairly boring so we add one more complication. The digits {0, 1,2,3,4,5,6,7,8,9} represent warp zones. In addition to the usual left and right movement these chars allow you to move to the matching digit (if present, a digit will appear exactly 2 times). Below is an example maze: X S 1 2 X F 2 X X 1 3 3 X X Convert a given 1D array to an equivalent graph. There should be a solution to the maze if and only if there is a path through the graph between the start and finish vertices. You can assume the first and last positions of the maze contain the char ‘X'. In addition to returning a graph, you should also store the index of the start and finish into the locations pointed to by 'ps' and 'pf'. Some helpful functions/reminders: //Creates and returns a new empty Graph Graph* createGraph(); //Adds an edge from vertex 'from' to vertex 'to'. //If needed also automatically creates vertices to represent the given integers. void addEdge Graph *g, int from, int to );

= = char int ‘O? 48 '1' 49 : '9' = 57 You can compare char values directly with ints or just use the function is Digit() to test if a given char is a digit. ==
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply