{"group":{"id":1,"name":"Community","lockable":false,"created_at":"2012-01-18T18:02:15.000Z","updated_at":"2026-04-06T14:01:22.000Z","description":"Problems submitted by members of the MATLAB Central community.","is_default":true,"created_by":161519,"badge_id":null,"featured":false,"trending":false,"solution_count_in_trending_period":0,"trending_last_calculated":"2026-04-06T00:00:00.000Z","image_id":null,"published":true,"community_created":false,"status_id":2,"is_default_group_for_player":false,"deleted_by":null,"deleted_at":null,"restored_by":null,"restored_at":null,"description_opc":null,"description_html":null,"published_at":null},"problems":[{"id":44378,"title":"Five-dimensional maze","description":"*Description*\r\n\r\nThe traditional maze is 2-dimensional: the navigator can move in the positive or negative directions along two axes _x_ and _y_. Now imagine, if you will, a 5-dimensional maze. As in the 2-dimensional case, the navigator may only move along one of these directions at any time, and some of the directions are blocked by walls. Your task is to find and give the shortest path through the given maze.\r\n\r\nThis problem is a generalization of \u003chttps://www.mathworks.com/matlabcentral/cody/problems/283 Problem 283\u003e. If you haven't solved that yet, I would recommend solving it first.\r\n\r\n*Encoding*\r\n\r\n* The maze will be represented by an [ _M_ x _N_ x _O_ x _P_ x _Q_ ] matrix. \r\n* Each element of the matrix represents a valid location in the maze and the value of each element is a binary-coded representation of the walls, positive directions in which you can not move. If a value reads 0, it means the navigator is permitted to move along any of the five dimensions in the positive direction.\r\n* Walls are bi-directional: if a wall exists between two locations, you cannot traverse it in either direction. A skilled navigator must check the destination location's walls if she wishes to move in the negative direction along any dimension.\r\n* The start position is at the origin: subscript |(1,1,1,1,1)|.\r\n* The end position is at the furthest extent: subscript |(M,N,O,P,Q)|.\r\n* The output should be a matrix of the same size as the input matrix that lists the steps you need to go through to traverse the maze with the remaining squares being 0. Refer to \u003chttps://www.mathworks.com/matlabcentral/cody/problems/283 Problem 283\u003e for a 2-D example.\r\n* You are *NOT* guaranteed that there will be only one shortest path for the test cases. If there exist multiple shortest paths, you must represent them all. It can easily be shown that the superposition of two shortest paths will never lead to a multi-valued element in the output matrix.","description_html":"\u003cp\u003e\u003cb\u003eDescription\u003c/b\u003e\u003c/p\u003e\u003cp\u003eThe traditional maze is 2-dimensional: the navigator can move in the positive or negative directions along two axes \u003ci\u003ex\u003c/i\u003e and \u003ci\u003ey\u003c/i\u003e. Now imagine, if you will, a 5-dimensional maze. As in the 2-dimensional case, the navigator may only move along one of these directions at any time, and some of the directions are blocked by walls. Your task is to find and give the shortest path through the given maze.\u003c/p\u003e\u003cp\u003eThis problem is a generalization of \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/283\"\u003eProblem 283\u003c/a\u003e. If you haven't solved that yet, I would recommend solving it first.\u003c/p\u003e\u003cp\u003e\u003cb\u003eEncoding\u003c/b\u003e\u003c/p\u003e\u003cul\u003e\u003cli\u003eThe maze will be represented by an [ \u003ci\u003eM\u003c/i\u003e x \u003ci\u003eN\u003c/i\u003e x \u003ci\u003eO\u003c/i\u003e x \u003ci\u003eP\u003c/i\u003e x \u003ci\u003eQ\u003c/i\u003e ] matrix.\u003c/li\u003e\u003cli\u003eEach element of the matrix represents a valid location in the maze and the value of each element is a binary-coded representation of the walls, positive directions in which you can not move. If a value reads 0, it means the navigator is permitted to move along any of the five dimensions in the positive direction.\u003c/li\u003e\u003cli\u003eWalls are bi-directional: if a wall exists between two locations, you cannot traverse it in either direction. A skilled navigator must check the destination location's walls if she wishes to move in the negative direction along any dimension.\u003c/li\u003e\u003cli\u003eThe start position is at the origin: subscript \u003ctt\u003e(1,1,1,1,1)\u003c/tt\u003e.\u003c/li\u003e\u003cli\u003eThe end position is at the furthest extent: subscript \u003ctt\u003e(M,N,O,P,Q)\u003c/tt\u003e.\u003c/li\u003e\u003cli\u003eThe output should be a matrix of the same size as the input matrix that lists the steps you need to go through to traverse the maze with the remaining squares being 0. Refer to \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/283\"\u003eProblem 283\u003c/a\u003e for a 2-D example.\u003c/li\u003e\u003cli\u003eYou are \u003cb\u003eNOT\u003c/b\u003e guaranteed that there will be only one shortest path for the test cases. If there exist multiple shortest paths, you must represent them all. It can easily be shown that the superposition of two shortest paths will never lead to a multi-valued element in the output matrix.\u003c/li\u003e\u003c/ul\u003e","function_template":"function path = solve_maze5(maze)\r\n    path = zeros(size(maze));\r\n    path(1) = 1;\r\nend","test_suite":"%%\r\nmaze = reshape([15 15 15 15 15 15 15 15 15 31], [1 1 1 1 10]);\r\ntruth = reshape([1 2 3 4 5 6 7 8 9 10], [1 1 1 1 10]);\r\nassert(isequal(solve_maze5(maze), truth));\r\n\r\n%%\r\nmaze = reshape([28 28 30 28 30 30 29 30 28 29 29 30 31 29 28 29 30 30 31 29 29 28 30 29 29 29 28 30 31 29 29 30 29 31 29 29 30 30 28 31 30 29 28 30 31 30 30 29 30 29 28 31 30 29 28 30 29 29 28 31 29 28 30 31 30 29 30 31 29 29 29 29 28 30 30 31 28 30 31 29 29 31 29 28 29 28 31 30 30 29 30 30 31 31 30 30 30 30 30 31], [10 10 1 1 1]);\r\ntruth = reshape([1 2 3 4 5 6 7 0 11 12 0 0 0 0 0 0 8 9 10 13 0 0 0 0 0 0 0 0 0 14 0 0 0 0 0 0 0 0 16 15 0 0 0 0 0 0 0 0 17 18 0 0 0 0 0 0 0 0 20 19 0 0 0 0 0 0 0 0 21 0 0 0 0 0 0 0 24 23 22 0 0 0 0 0 0 26 25 0 0 0 0 0 0 0 0 27 28 29 30 31], [10 10 1 1 1]);\r\nassert(isequal(solve_maze5(maze), truth));\r\n\r\n%%\r\nmaze = reshape([20 29 22 23 23 23 22 30 29 21 28 29 23 29 29 29 30 29 29 29 23 22 31 30 31 23 23 29 23 21 29 29 23 22 31 23 23 22 22 31 28 23 21 28 29 31 23 30 31 23 30 22 31 23 23 28 30 31 29 21 31 29 31 21 29 22 31 29 29 29 23 23 23 31 23 22 31 22 31 31 28 23 28 23 23 23 22 31 30 23 28 23 23 28 23 31 30 31 23 23 28 31 29 28 29 31 29 29 31 31 29 31 30 29 31 29 30 31 30 31 30 30 30 31 31], [5 5 1 5 1]);\r\ntruth = reshape([1 2 0 0 0 0 3 0 0 0 13 14 0 0 0 12 15 16 0 0 11 18 17 0 0 0 0 0 0 0 0 4 0 0 0 0 5 0 0 0 9 8 25 28 29 10 19 26 27 30 0 0 0 0 0 0 0 0 0 0 0 6 0 0 0 0 7 24 0 0 0 20 23 0 31 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 21 22 0 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 33], [5 5 1 5 1]);\r\nassert(isequal(solve_maze5(maze), truth));\r\n\r\n%%\r\nmaze = reshape([18 23 19 28 27 22 23 22 31 19 25 22 29 25 21 27 25 29 27 29 30 30 31 22 31 29 23 29 29 29 29 21 29 21 31 31 30 31 31 29 29 29 21 29 29 23 23 23 30 31 23 23 29 27 19 27 27 31 22 31 30 23 28 23 27 22 29 29 19 25 19 30 31 27 23 30 22 30 28 31 29 31 21 23 23 30 29 29 21 29 22 31 31 31 31 31 30 31 30 23 27 23 22 23 29 17 19 29 23 29 25 23 19 27 29 31 22 30 31 29 18 31 19 27 31 23 31 21 28 29 31 23 31 31 29 30 29 29 31 29 23 29 30 28 31 23 30 31 31 23 19 27 29 23 27 31 30 31 27 25 19 27 30 30 31 22 31 21 26 27 31 19 31 22 23 31 30 31 22 29 28 31 28 31 31 31 29 23 21 21 23 30 23 31 31 23 23 22 30 31 29 26 31 30 29 27 26 30 29 29 30 30 30 31 27 29 26 31 25 25 30 31 27 31 31 30 30 28 31 29 30 31 30 30 31 28 29 30 31 31 31 31 30 31 29 30 31 30 30 31], [5 5 2 5 1]);\r\ntruth = reshape([1 2 0 0 0 0 0 0 0 0 0 24 23 0 0 0 19 22 0 0 0 20 21 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 18 13 0 0 0 17 14 0 0 0 3 0 0 0 0 0 0 0 0 0 25 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 0 0 0 0 11 0 0 0 0 12 0 0 0 16 15 0 0 0 4 0 0 0 0 0 0 0 0 0 26 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8 0 0 0 0 9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 0 0 0 0 0 0 0 0 0 27 0 0 0 0 0 0 0 0 0 0 0 35 36 0 6 7 0 0 0 0 0 0 0 0 28 0 0 0 0 29 30 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 33 38 0 0 0 34 37 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 31 32 39 0 0 0 0 40], [5 5 2 5 1]);\r\nassert(isequal(solve_maze5(maze), truth));\r\n\r\n%%\r\nmaze = reshape([21 5 22 29 19 23 31 7 30 15 21 26 23 7 19 23 22 29 11 11 14 15 30 30 23 11 7 11 25 15 13 13 15 15 27 23 31 28 29 27 13 14 31 31 15 23 14 23 30 19 30 30 31 29 25 7 14 29 23 31 25 27 30 29 23 30 29 12 31 19 7 23 31 19 11 28 30 15 26 27 15 13 25 26 23 27 23 23 28 15 19 20 23 27 15 7 31 19 23 27 28 23 22 31 15 30 23 29 30 15 15 28 31 23 21 23 30 23 29 23 22 15 15 23 23 26 15 23 7 29 23 28 31 25 15 23 27 27 31 23 29 23 14 29 25 23 7 15 23 31 27 30 15 25 21 28 23 19 31 15 31 27 23 19 23 22 30 30 27 15 30 15 27 7 23 30 27 26 31 25 23 19 30 31 23 29 29 14 31 27 23 30 23 15 23 23 23 30 31 19 7 23 23 25 27 26 27 23 13 23 21 31 23 27 15 31 15 29 26 23 15 19 31 23 15 29 23 30 31 15 31 31 7 28 31 14 23 13 23 15 29 21 31 30 31 31 31 23 30 31 26 27 25 31 21 15 21 31 28 31 15 23 21 29 29 26 31 29 27 29 30 31 27 15 15 27 23 23 13 27 25 23 23 29 19 30 27 27 31 19 31 28 27 15 29 15 23 23 23 15 15 26 31 5 15 31 30 15 29 31 26 31 30 31 29 15 13 31 17 31 27 31 27 15 15 27 31 30 30 27 11 13 23 19 29 31 27 29 14 31 28 29 27 27 15 31 31 27 30 23 30 31 15 13 15 15 15 29 31 13 13 31 15 31 29 29 29 23 23 23 15 23 30 23 7 22 27 7 19 29 25 30 30 30 31 23 29 23 30 25 11 29 7 22 31 26 31 26 30 27 29 31 27 28 27 15 15 27 27 27 28 30 27 19 31 31 14 15 27 21 30 31 31 23 31 19 28 31 27 15 21 21 23 31 29 27 31 29 23 15 22 29 29 31 25 27 23 15 7 15 29 25 13 30 29 15 27 21 27 23 30 15 29 26 23 28 29 15 22 31 27 23 3 14 31 13 15 14 30 29 29 15 23 23 29 31 14 30 31 23 22 23 15 15 29 23 15 23 15 31 15 30 28 30 29 28 27 31 11 27 31 13 30 15 11 13 28 31 15 11 15 27 14 30 15 28 27 28 15 11 30 31 15 29 13 28 30 27 31 31 30 30 30 27 31 30 31 26 31 15 15 29 28 15 27 25 31 31 13 13 31 26 31 31 29 29 27 26 31 29 27 30 31 30 31 25 28 27 30 31 31 27 27 28 31 26 31 26 31 15 26 29 30 31 27 15 31 31 14 27 29 15 15 14 15 30 31 31 29 15 30 15 30 31 15 31 29 30 30 15 15 15 15 14 31 25 30 30 18 31 15 21 23 14 31 7 30 29 15 13 14 27 27 23 31 23 27 7 26 27 31 27 23 31 29 29 15 15 15 29 30 15 19 21 15 29 31 29 29 27 15 31 23 31 23 21 29 13 22 15 31 31 27 25 11 14 29 29 22 31 28 31 31 11 27 31 14 30 30 31 7 22 31 25 13 23 25 27 23 31 25 23 25 22 31 29 28 31 27 31 31 27 30 26 15 21 23 21 29 15 15 23 31 15 23 31 13 30 30 23 28 31 21 15 13 23 31 31 22 31 19 31 7 30 23 26 31 30 29 15 30 15 22 31 15 19 28 31 30 23 23 31 26 31 7 15 7 27 14 29 29 26 30 27 31 23 26 31 23 25 30 30 14 31 31 26 31 27 30 31 23 11 31 15 21 7 23 28 31 23 26 31 31 31 27 26 30 30 31 25 30 23 31 14 31 31 31 21 26 15 30 30 31 31 7 15 23 28 31 31 15 29 27 13 15 15 30 30 31 27 29 23 29 29 15 23 23 31 30 31 30 23 30 29 31 28 31 31 15 15 15 14 15 31 15 30 23 27 7 17 30 15 19 13 31 27 7 23 30 23 31 22 27 29 27 30 23 22 31 31 22 31 23 15 15 22 29 15 19 11 31 23 19 30 29 22 23 27 23 31 19 19 22 15 31 31 11 19 31 31 31 29 30 31 31 19 29 29 14 29 29 31 31 25 29 31 31 19 31 31 27 29 31 11 19 29 31 28 30 31 31 29 23 30 15 14 29 13 23 29 7 27 31 14 31 22 30 31 31 31 31 15 7 13 15 15 29 30 31 23 7 23 15 14 15 15 31 14 15 23 21 23 31 27 27 30 23 27 28 27 27 27 15 29 27 27 29 21 30 27 27 31 31 14 27 15 11 23 27 23 31 23 27 23 15 15 31 30 15 23 31 31 15 23 27 15 27 30 30 31 25 27 30 31 23 30 29 30 27 27 15 30 27 14 31 14 23 27 13 27 7 27 31 31 23 15 27 23 19 15 29 22 30 31 25 27 23 31 25 27 21 7 23 31 23 31 15 27 15 15 21 31 15 29 15 15 29 29 15 7 15 31 29 23 29 30 31 31 23 7 14 31 30 15 15 31 30 30 30 29 25 15 11 15 15 27 29 29 29 31 30 31 31 31 15 15 14 31 11 27 28 27 27 29 29 31 27 31 31 31 29 28 30 29 15 27 30 29 31 9 14 27 27 15 31 15 15 30 31 27 11 29 13 15 29 13 30 31 25 15 31 30 30 31 29 15 30 31 11 31 13 14 31 30 31 31 15 28 30 29 26 31 27 27 15 30 31 30 15 29 15 30 11 31 27 29 14 31 29 15 31 14 29 15 31 30 31 31 31 15 28 30 30 31 15 31 15 31 30 31 7 28 30 15 13 15 30 23 15 15 15 21 21 30 31 29 23 27 7 27 23 23 23 22 15 24 30 29 19 21 21 15 31 27 23 31 30 29 28 31 22 15 31 29 29 30 23 30 23 23 31 11 27 15 23 25 28 15 29 29 31 30 23 29 29 23 11 19 31 27 19 27 19 26 27 23 23 29 7 23 23 7 30 29 9 30 11 15 23 15 25 27 30 15 15 31 27 15 27 31 14 30 29 14 31 29 13 29 29 31 23 31 15 23 7 30 31 21 23 15 23 15 30 31 15 30 27 30 15 19 22 27 30 28 31 13 31 29 30 31 29 27 30 31 13 31 30 27 23 31 27 31 21 31 31 27 15 27 14 31 22 15 11 25 19 30 31 27 30 23 19 23 30 31 15 23 29 26 31 29 15 27 30 29 15 28 27 31 31 27 23 21 14 30 29 31 23 23 23 15 29 30 31 27 31 31 31 19 26 31 15 15 28 31 23 30 29 23 29 23 30 31 26 31 23 22 29 29 29 29 28 31 29 31 15 31 22 31 30 29 14 30 31 31 31 31 23 31 14 31 11 15 11 23 29 30 31 22 31 23 29 29 19 24 27 26 31 22 31 13 26 15 14 31 31 30 29 31 23 11 13 30 31 14 31 31 7 23 31 31 14 31 11 25 27 31 15 23 31 19 27 15 7 13 19 28 15 25 15 7 30 27 27 27 15 30 31 15 23 15 14 31 27 30 31 27 19 29 29 31 21 7 31 30 23 30 31 27 27 31 30 29 31 13 15 27 15 27 31 7 31 15 7 22 29 7 29 15 15 31 23 31 29 15 13 15 30 15 23 31 31 23 31 30 23 29 11 7 30 27 11 27 27 25 15 28 23 31 15 19 15 28 31 11 13 11 30 23 30 31 27 31 27 30 31 11 7 29 29 23 29 15 31 31 29 29 22 31 23 15 15 14 11 19 23 30 23 30 27 23 31 19 22 15 29 23 21 21 15 29 30 15 15 31 29 27 30 31 30 31 23 30 29 15 15 29 31 29 21 15 30 23 15 27 11 21 27 22 30 25 31 23 7 23 31 14 23 31 15 29 15 14 23 23 15 31 23 14 31 23 7 23 7 15 31 15 15 30 15 31 13 11 27 13 13 30 31 29 31 31 14 31 15 11 27 28 30 28 31 15 31 15 31 30 27 25 29 30 29 27 15 31 14 31 15 28 30 30 31 31 27 29 27 15 31 15 30 27 31 31 31 31 26 29 29 30 31 31 31 15 31 31 27 26 31 27 25 30 27 11 30 31 15 30 15 31 31 30 30 15 30 30 15 30 27 14 31 30 31 31 31 29 14 31 15 15 31 31 27 27 13 31 28 15 15 30 31 31 31 15 14 31 13 13 31 29 15 31 15 29 30 31 14 31 31 30 27 21 30 31 30 29 27 30 31 23 29 28 15 21 21 15 30 31 29 15 22 15 11 31 25 27 11 30 25 27 27 15 13 15 11 26 31 27 7 22 31 25 26 29 22 30 31 27 15 23 31 27 27 21 29 23 27 30 27 31 27 14 31 7 28 31 15 26 31 15 7 23 30 15 28 31 29 31 25 25 23 31 13 31 27 14 31 15 31 26 15 7 31 27 19 19 23 11 7 30 15 13 15 29 30 7 30 23 15 23 14 31 21 15 15 22 30 31 31 15 31 7 30 15 30 7 29 30 27 26 27 30 29 13 31 22 29 23 31 30 31 27 19 27 22 31 26 15 15 14 30 30 23 15 23 31 26 31 25 22 31 27 11 31 29 25 30 31 27 31 15 23 22 27 30 30 15 19 31 25 29 23 7 31 29 27 23 27 27 29 29 29 28 31 15 31 31 23 31 21 13 21 29 19 31 31 29 23 21 29 31 23 15 31 27 28 31 26 15 27 31 15 26 31 21 7 14 30 31 29 20 30 31 15 31 31 13 30 29 31 29 30 31 29 30 31 23 31 15 27 11 15 22 23 14 27 15 7 15 25 30 29 29 11 23 28 31 31 27 27 31 30 30 15 23 31 22 31 31 31 23 21 30 29 31 29 30 23 31 27 30 31 22 15 15 30 31 15 19 14 31 29 31 13 22 31 31 31 31 25 27 23 25 19 31 11 30 31 27 27 27 22 31 23 26 31 27 19 27 15 30 23 15 27 30 15 29 15 31 7 27 30 31 31 27 15 30 22 27 31 31 31 15 15 14 31 30 31 15 14 29 13 30 31 15 31 31 7 29 30 15 30 23 23 22 31 27 15 27 15 21 28 31 7 15 15 15 23 13 31 13 25 23 31 23 31 22 30 23 30 27 31 11 15 15 31 30 15 25 14 31 22 31 27 26 29 23 31 27 15 31 23 11 23 22 31 21 15 19 29 14 31 23 23 23 7 15 29 15 23 29 30 31 27 14 31 15 23 23 28 30 23 29 31 29 19 27 29 15 23 25 29 31 15 29 15 27 14 31 30 30 31 31 7 30 30 30 31 7 29 31 29 13 29 23 29 31 23 23 15 29 31 31 7 23 31 7 31 15 31 15 26 31 15 13 29 13 30 31 31 29 31 31 13 29 30 30 31 31 15 27 30 27 31 11 28 31 28 15 27 29 27 29 15 13 15 27 15 13 29 25 15 30 31 31 31 15 15 15 31 25 30 15 15 29 30 31 29 31 31 29 27 27 25 25 31 28 27 31 14 31 31 27 31 28 31 15 13 29 27 15 30 31 15 31 15 30 31 15 15 13 11 27 15 30 31 14 31 15 29 28 29 29 31 31 15 31 15 15 31 14 31 31 31 28 31 31 31 29 31 15 31 14 31 30 18 22 30 31 26 23 22 30 25 22 29 26 31 31 19 31 28 30 23 26 31 31 27 23 25 29 23 22 27 31 31 23 27 31 30 30 31 27 29 23 21 22 27 27 22 30 23 30 31 27 26 29 26 31 29 25 23 30 27 29 29 29 27 23 27 23 31 23 23 30 31 26 30 31 29 23 28 31 19 27 23 29 23 23 26 23 27 30 23 28 27 30 27 27 23 23 30 27 23 22 31 31 30 31 23 31 22 29 29 29 23 29 29 29 31 31 23 31 23 30 30 31 31 23 21 31 29 28 23 29 27 31 27 27 31 25 25 22 27 29 23 30 29 23 30 23 19 31 27 29 25 23 21 27 27 31 23 31 23 21 29 23 23 23 31 31 23 30 23 27 27 31 22 23 25 29 27 26 31 31 27 30 31 23 21 22 23 26 31 23 27 22 31 23 31 30 27 26 27 27 31 30 31 23 23 31 28 31 27 19 31 21 31 29 25 27 31 21 31 30 31 31 31 31 31 30 31 22 23 29 21 30 29 31 31 31 23 29 23 31 29 29 29 23 22 31 30 31 31 27 29 30 29 21 23 29 29 31 23 28 31 29 23 23 29 23 29 19 23 23 23 30 31 23 29 22 31 27 19 29 25 29 28 31 31 29 31 31 21 21 23 30 31 31 31 26 23 31 27 23 19 30 31 31 28 31 22 27 19 31 29 29 21 25 29 31 31 31 31 30 31 27 26 31 23 30 30 23 29 18 31 25 31 31 30 31 31 23 23 29 29 22 31 21 27 30 30 31 19 22 23 23 31 31 31 29 23 29 23 30 31 31 30 21 30 30 30 31 31 31 23 30 22 31 26 30 29 27 31 31 28 31 29 31 21 31 29 27 31 29 23 30 31 23 31 23 26 23 23 27 27 19 31 31 23 26 30 31 25 23 25 19 27 31 27 31 26 23 25 23 19 31 30 31 31 31 23 29 29 21 31 23 27 31 27 31 31 21 29 27 29 29 23 31 27 27 31 30 19 29 26 29 30 23 31 25 30 31 27 29 27 19 23 31 31 29 30 31 31 23 31 22 23 31 23 31 30 30 23 28 31 29 29 31 23 23 31 29 29 23 23 28 31 31 22 31 31 30 31 30 27 30 27 27 30 29 29 26 29 29 27 30 29 31 29 27 28 31 29 31 27 30 31 31 29 30 30 31 31 31 26 30 31 29 31 31 30 31 31 28 31 27 30 29 31 31 27 27 31 28 30 31 27 27 31 30 31 29 25 25 26 30 31 27 30 27 30 31 29 30 27 30 31 31 26 30 31 31 31 28 31 27 25 31 31 31 27 31 31 31 31 31 25 27 27 27 31 31 27 31 28 28 30 31 30 31 29 31 29 29 31 31 29 29 31 29 28 31 31 31 30 31 30 31], [5 5 5 5 5]);\r\ntruth = reshape([1 4 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 93 92 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 95 94 91 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 3 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 98 0 0 0 0 99 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 96 97 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 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0 0 0 0 0 82 0 0 0 0 81 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 115 0 0 0 0 114 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 71 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 78 0 0 0 70 77 0 0 0 0 24 0 0 0 26 25 0 0 0 0 0 0 0 0 0 79 0 0 0 69 22 0 0 0 68 23 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 33 34 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 116 0 0 0 0 117 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 65 0 0 0 0 54 57 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 66 67 0 43 42 55 56 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 36 0 0 41 32 35 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 38 37 0 0 40 39 122 123], [5 5 5 5 5]);\r\nassert(isequal(solve_maze5(maze), truth));","published":true,"deleted":false,"likes_count":5,"comments_count":19,"created_by":134,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":48,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":35,"created_at":"2017-10-12T15:00:57.000Z","updated_at":"2026-03-19T20:06:56.000Z","published_at":"2017-10-16T01:51:01.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eDescription\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe traditional maze is 2-dimensional: the navigator can move in the positive or negative directions along two axes\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ex\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ey\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e. Now imagine, if you will, a 5-dimensional maze. As in the 2-dimensional case, the navigator may only move along one of these directions at any time, and some of the directions are blocked by walls. Your task is to find and give the shortest path through the given maze.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis problem is a generalization of\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/283\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 283\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. If you haven't solved that yet, I would recommend solving it first.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eEncoding\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe maze will be represented by an [\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eM\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e x\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eN\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e x\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eO\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e x\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eP\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e x\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eQ\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e ] matrix.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEach element of the matrix represents a valid location in the maze and the value of each element is a binary-coded representation of the walls, positive directions in which you can not move. If a value reads 0, it means the navigator is permitted to move along any of the five dimensions in the positive direction.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWalls are bi-directional: if a wall exists between two locations, you cannot traverse it in either direction. A skilled navigator must check the destination location's walls if she wishes to move in the negative direction along any dimension.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe start position is at the origin: subscript\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e(1,1,1,1,1)\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe end position is at the furthest extent: subscript\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e(M,N,O,P,Q)\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe output should be a matrix of the same size as the input matrix that lists the steps you need to go through to traverse the maze with the remaining squares being 0. Refer to\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/283\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 283\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e for a 2-D example.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou are\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eNOT\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e guaranteed that there will be only one shortest path for the test cases. If there exist multiple shortest paths, you must represent them all. It can easily be shown that the superposition of two shortest paths will never lead to a multi-valued element in the output matrix.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"}],"problem_search":{"errors":[],"problems":[{"id":44378,"title":"Five-dimensional maze","description":"*Description*\r\n\r\nThe traditional maze is 2-dimensional: the navigator can move in the positive or negative directions along two axes _x_ and _y_. Now imagine, if you will, a 5-dimensional maze. As in the 2-dimensional case, the navigator may only move along one of these directions at any time, and some of the directions are blocked by walls. Your task is to find and give the shortest path through the given maze.\r\n\r\nThis problem is a generalization of \u003chttps://www.mathworks.com/matlabcentral/cody/problems/283 Problem 283\u003e. If you haven't solved that yet, I would recommend solving it first.\r\n\r\n*Encoding*\r\n\r\n* The maze will be represented by an [ _M_ x _N_ x _O_ x _P_ x _Q_ ] matrix. \r\n* Each element of the matrix represents a valid location in the maze and the value of each element is a binary-coded representation of the walls, positive directions in which you can not move. If a value reads 0, it means the navigator is permitted to move along any of the five dimensions in the positive direction.\r\n* Walls are bi-directional: if a wall exists between two locations, you cannot traverse it in either direction. A skilled navigator must check the destination location's walls if she wishes to move in the negative direction along any dimension.\r\n* The start position is at the origin: subscript |(1,1,1,1,1)|.\r\n* The end position is at the furthest extent: subscript |(M,N,O,P,Q)|.\r\n* The output should be a matrix of the same size as the input matrix that lists the steps you need to go through to traverse the maze with the remaining squares being 0. Refer to \u003chttps://www.mathworks.com/matlabcentral/cody/problems/283 Problem 283\u003e for a 2-D example.\r\n* You are *NOT* guaranteed that there will be only one shortest path for the test cases. If there exist multiple shortest paths, you must represent them all. It can easily be shown that the superposition of two shortest paths will never lead to a multi-valued element in the output matrix.","description_html":"\u003cp\u003e\u003cb\u003eDescription\u003c/b\u003e\u003c/p\u003e\u003cp\u003eThe traditional maze is 2-dimensional: the navigator can move in the positive or negative directions along two axes \u003ci\u003ex\u003c/i\u003e and \u003ci\u003ey\u003c/i\u003e. Now imagine, if you will, a 5-dimensional maze. As in the 2-dimensional case, the navigator may only move along one of these directions at any time, and some of the directions are blocked by walls. Your task is to find and give the shortest path through the given maze.\u003c/p\u003e\u003cp\u003eThis problem is a generalization of \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/283\"\u003eProblem 283\u003c/a\u003e. If you haven't solved that yet, I would recommend solving it first.\u003c/p\u003e\u003cp\u003e\u003cb\u003eEncoding\u003c/b\u003e\u003c/p\u003e\u003cul\u003e\u003cli\u003eThe maze will be represented by an [ \u003ci\u003eM\u003c/i\u003e x \u003ci\u003eN\u003c/i\u003e x \u003ci\u003eO\u003c/i\u003e x \u003ci\u003eP\u003c/i\u003e x \u003ci\u003eQ\u003c/i\u003e ] matrix.\u003c/li\u003e\u003cli\u003eEach element of the matrix represents a valid location in the maze and the value of each element is a binary-coded representation of the walls, positive directions in which you can not move. If a value reads 0, it means the navigator is permitted to move along any of the five dimensions in the positive direction.\u003c/li\u003e\u003cli\u003eWalls are bi-directional: if a wall exists between two locations, you cannot traverse it in either direction. A skilled navigator must check the destination location's walls if she wishes to move in the negative direction along any dimension.\u003c/li\u003e\u003cli\u003eThe start position is at the origin: subscript \u003ctt\u003e(1,1,1,1,1)\u003c/tt\u003e.\u003c/li\u003e\u003cli\u003eThe end position is at the furthest extent: subscript \u003ctt\u003e(M,N,O,P,Q)\u003c/tt\u003e.\u003c/li\u003e\u003cli\u003eThe output should be a matrix of the same size as the input matrix that lists the steps you need to go through to traverse the maze with the remaining squares being 0. Refer to \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/283\"\u003eProblem 283\u003c/a\u003e for a 2-D example.\u003c/li\u003e\u003cli\u003eYou are \u003cb\u003eNOT\u003c/b\u003e guaranteed that there will be only one shortest path for the test cases. If there exist multiple shortest paths, you must represent them all. It can easily be shown that the superposition of two shortest paths will never lead to a multi-valued element in the output matrix.\u003c/li\u003e\u003c/ul\u003e","function_template":"function path = solve_maze5(maze)\r\n    path = zeros(size(maze));\r\n    path(1) = 1;\r\nend","test_suite":"%%\r\nmaze = reshape([15 15 15 15 15 15 15 15 15 31], [1 1 1 1 10]);\r\ntruth = reshape([1 2 3 4 5 6 7 8 9 10], [1 1 1 1 10]);\r\nassert(isequal(solve_maze5(maze), truth));\r\n\r\n%%\r\nmaze = reshape([28 28 30 28 30 30 29 30 28 29 29 30 31 29 28 29 30 30 31 29 29 28 30 29 29 29 28 30 31 29 29 30 29 31 29 29 30 30 28 31 30 29 28 30 31 30 30 29 30 29 28 31 30 29 28 30 29 29 28 31 29 28 30 31 30 29 30 31 29 29 29 29 28 30 30 31 28 30 31 29 29 31 29 28 29 28 31 30 30 29 30 30 31 31 30 30 30 30 30 31], [10 10 1 1 1]);\r\ntruth = reshape([1 2 3 4 5 6 7 0 11 12 0 0 0 0 0 0 8 9 10 13 0 0 0 0 0 0 0 0 0 14 0 0 0 0 0 0 0 0 16 15 0 0 0 0 0 0 0 0 17 18 0 0 0 0 0 0 0 0 20 19 0 0 0 0 0 0 0 0 21 0 0 0 0 0 0 0 24 23 22 0 0 0 0 0 0 26 25 0 0 0 0 0 0 0 0 27 28 29 30 31], [10 10 1 1 1]);\r\nassert(isequal(solve_maze5(maze), truth));\r\n\r\n%%\r\nmaze = reshape([20 29 22 23 23 23 22 30 29 21 28 29 23 29 29 29 30 29 29 29 23 22 31 30 31 23 23 29 23 21 29 29 23 22 31 23 23 22 22 31 28 23 21 28 29 31 23 30 31 23 30 22 31 23 23 28 30 31 29 21 31 29 31 21 29 22 31 29 29 29 23 23 23 31 23 22 31 22 31 31 28 23 28 23 23 23 22 31 30 23 28 23 23 28 23 31 30 31 23 23 28 31 29 28 29 31 29 29 31 31 29 31 30 29 31 29 30 31 30 31 30 30 30 31 31], [5 5 1 5 1]);\r\ntruth = reshape([1 2 0 0 0 0 3 0 0 0 13 14 0 0 0 12 15 16 0 0 11 18 17 0 0 0 0 0 0 0 0 4 0 0 0 0 5 0 0 0 9 8 25 28 29 10 19 26 27 30 0 0 0 0 0 0 0 0 0 0 0 6 0 0 0 0 7 24 0 0 0 20 23 0 31 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 21 22 0 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 33], [5 5 1 5 1]);\r\nassert(isequal(solve_maze5(maze), truth));\r\n\r\n%%\r\nmaze = reshape([18 23 19 28 27 22 23 22 31 19 25 22 29 25 21 27 25 29 27 29 30 30 31 22 31 29 23 29 29 29 29 21 29 21 31 31 30 31 31 29 29 29 21 29 29 23 23 23 30 31 23 23 29 27 19 27 27 31 22 31 30 23 28 23 27 22 29 29 19 25 19 30 31 27 23 30 22 30 28 31 29 31 21 23 23 30 29 29 21 29 22 31 31 31 31 31 30 31 30 23 27 23 22 23 29 17 19 29 23 29 25 23 19 27 29 31 22 30 31 29 18 31 19 27 31 23 31 21 28 29 31 23 31 31 29 30 29 29 31 29 23 29 30 28 31 23 30 31 31 23 19 27 29 23 27 31 30 31 27 25 19 27 30 30 31 22 31 21 26 27 31 19 31 22 23 31 30 31 22 29 28 31 28 31 31 31 29 23 21 21 23 30 23 31 31 23 23 22 30 31 29 26 31 30 29 27 26 30 29 29 30 30 30 31 27 29 26 31 25 25 30 31 27 31 31 30 30 28 31 29 30 31 30 30 31 28 29 30 31 31 31 31 30 31 29 30 31 30 30 31], [5 5 2 5 1]);\r\ntruth = reshape([1 2 0 0 0 0 0 0 0 0 0 24 23 0 0 0 19 22 0 0 0 20 21 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 18 13 0 0 0 17 14 0 0 0 3 0 0 0 0 0 0 0 0 0 25 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 0 0 0 0 11 0 0 0 0 12 0 0 0 16 15 0 0 0 4 0 0 0 0 0 0 0 0 0 26 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8 0 0 0 0 9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 0 0 0 0 0 0 0 0 0 27 0 0 0 0 0 0 0 0 0 0 0 35 36 0 6 7 0 0 0 0 0 0 0 0 28 0 0 0 0 29 30 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 33 38 0 0 0 34 37 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 31 32 39 0 0 0 0 40], [5 5 2 5 1]);\r\nassert(isequal(solve_maze5(maze), truth));\r\n\r\n%%\r\nmaze = reshape([21 5 22 29 19 23 31 7 30 15 21 26 23 7 19 23 22 29 11 11 14 15 30 30 23 11 7 11 25 15 13 13 15 15 27 23 31 28 29 27 13 14 31 31 15 23 14 23 30 19 30 30 31 29 25 7 14 29 23 31 25 27 30 29 23 30 29 12 31 19 7 23 31 19 11 28 30 15 26 27 15 13 25 26 23 27 23 23 28 15 19 20 23 27 15 7 31 19 23 27 28 23 22 31 15 30 23 29 30 15 15 28 31 23 21 23 30 23 29 23 22 15 15 23 23 26 15 23 7 29 23 28 31 25 15 23 27 27 31 23 29 23 14 29 25 23 7 15 23 31 27 30 15 25 21 28 23 19 31 15 31 27 23 19 23 22 30 30 27 15 30 15 27 7 23 30 27 26 31 25 23 19 30 31 23 29 29 14 31 27 23 30 23 15 23 23 23 30 31 19 7 23 23 25 27 26 27 23 13 23 21 31 23 27 15 31 15 29 26 23 15 19 31 23 15 29 23 30 31 15 31 31 7 28 31 14 23 13 23 15 29 21 31 30 31 31 31 23 30 31 26 27 25 31 21 15 21 31 28 31 15 23 21 29 29 26 31 29 27 29 30 31 27 15 15 27 23 23 13 27 25 23 23 29 19 30 27 27 31 19 31 28 27 15 29 15 23 23 23 15 15 26 31 5 15 31 30 15 29 31 26 31 30 31 29 15 13 31 17 31 27 31 27 15 15 27 31 30 30 27 11 13 23 19 29 31 27 29 14 31 28 29 27 27 15 31 31 27 30 23 30 31 15 13 15 15 15 29 31 13 13 31 15 31 29 29 29 23 23 23 15 23 30 23 7 22 27 7 19 29 25 30 30 30 31 23 29 23 30 25 11 29 7 22 31 26 31 26 30 27 29 31 27 28 27 15 15 27 27 27 28 30 27 19 31 31 14 15 27 21 30 31 31 23 31 19 28 31 27 15 21 21 23 31 29 27 31 29 23 15 22 29 29 31 25 27 23 15 7 15 29 25 13 30 29 15 27 21 27 23 30 15 29 26 23 28 29 15 22 31 27 23 3 14 31 13 15 14 30 29 29 15 23 23 29 31 14 30 31 23 22 23 15 15 29 23 15 23 15 31 15 30 28 30 29 28 27 31 11 27 31 13 30 15 11 13 28 31 15 11 15 27 14 30 15 28 27 28 15 11 30 31 15 29 13 28 30 27 31 31 30 30 30 27 31 30 31 26 31 15 15 29 28 15 27 25 31 31 13 13 31 26 31 31 29 29 27 26 31 29 27 30 31 30 31 25 28 27 30 31 31 27 27 28 31 26 31 26 31 15 26 29 30 31 27 15 31 31 14 27 29 15 15 14 15 30 31 31 29 15 30 15 30 31 15 31 29 30 30 15 15 15 15 14 31 25 30 30 18 31 15 21 23 14 31 7 30 29 15 13 14 27 27 23 31 23 27 7 26 27 31 27 23 31 29 29 15 15 15 29 30 15 19 21 15 29 31 29 29 27 15 31 23 31 23 21 29 13 22 15 31 31 27 25 11 14 29 29 22 31 28 31 31 11 27 31 14 30 30 31 7 22 31 25 13 23 25 27 23 31 25 23 25 22 31 29 28 31 27 31 31 27 30 26 15 21 23 21 29 15 15 23 31 15 23 31 13 30 30 23 28 31 21 15 13 23 31 31 22 31 19 31 7 30 23 26 31 30 29 15 30 15 22 31 15 19 28 31 30 23 23 31 26 31 7 15 7 27 14 29 29 26 30 27 31 23 26 31 23 25 30 30 14 31 31 26 31 27 30 31 23 11 31 15 21 7 23 28 31 23 26 31 31 31 27 26 30 30 31 25 30 23 31 14 31 31 31 21 26 15 30 30 31 31 7 15 23 28 31 31 15 29 27 13 15 15 30 30 31 27 29 23 29 29 15 23 23 31 30 31 30 23 30 29 31 28 31 31 15 15 15 14 15 31 15 30 23 27 7 17 30 15 19 13 31 27 7 23 30 23 31 22 27 29 27 30 23 22 31 31 22 31 23 15 15 22 29 15 19 11 31 23 19 30 29 22 23 27 23 31 19 19 22 15 31 31 11 19 31 31 31 29 30 31 31 19 29 29 14 29 29 31 31 25 29 31 31 19 31 31 27 29 31 11 19 29 31 28 30 31 31 29 23 30 15 14 29 13 23 29 7 27 31 14 31 22 30 31 31 31 31 15 7 13 15 15 29 30 31 23 7 23 15 14 15 15 31 14 15 23 21 23 31 27 27 30 23 27 28 27 27 27 15 29 27 27 29 21 30 27 27 31 31 14 27 15 11 23 27 23 31 23 27 23 15 15 31 30 15 23 31 31 15 23 27 15 27 30 30 31 25 27 30 31 23 30 29 30 27 27 15 30 27 14 31 14 23 27 13 27 7 27 31 31 23 15 27 23 19 15 29 22 30 31 25 27 23 31 25 27 21 7 23 31 23 31 15 27 15 15 21 31 15 29 15 15 29 29 15 7 15 31 29 23 29 30 31 31 23 7 14 31 30 15 15 31 30 30 30 29 25 15 11 15 15 27 29 29 29 31 30 31 31 31 15 15 14 31 11 27 28 27 27 29 29 31 27 31 31 31 29 28 30 29 15 27 30 29 31 9 14 27 27 15 31 15 15 30 31 27 11 29 13 15 29 13 30 31 25 15 31 30 30 31 29 15 30 31 11 31 13 14 31 30 31 31 15 28 30 29 26 31 27 27 15 30 31 30 15 29 15 30 11 31 27 29 14 31 29 15 31 14 29 15 31 30 31 31 31 15 28 30 30 31 15 31 15 31 30 31 7 28 30 15 13 15 30 23 15 15 15 21 21 30 31 29 23 27 7 27 23 23 23 22 15 24 30 29 19 21 21 15 31 27 23 31 30 29 28 31 22 15 31 29 29 30 23 30 23 23 31 11 27 15 23 25 28 15 29 29 31 30 23 29 29 23 11 19 31 27 19 27 19 26 27 23 23 29 7 23 23 7 30 29 9 30 11 15 23 15 25 27 30 15 15 31 27 15 27 31 14 30 29 14 31 29 13 29 29 31 23 31 15 23 7 30 31 21 23 15 23 15 30 31 15 30 27 30 15 19 22 27 30 28 31 13 31 29 30 31 29 27 30 31 13 31 30 27 23 31 27 31 21 31 31 27 15 27 14 31 22 15 11 25 19 30 31 27 30 23 19 23 30 31 15 23 29 26 31 29 15 27 30 29 15 28 27 31 31 27 23 21 14 30 29 31 23 23 23 15 29 30 31 27 31 31 31 19 26 31 15 15 28 31 23 30 29 23 29 23 30 31 26 31 23 22 29 29 29 29 28 31 29 31 15 31 22 31 30 29 14 30 31 31 31 31 23 31 14 31 11 15 11 23 29 30 31 22 31 23 29 29 19 24 27 26 31 22 31 13 26 15 14 31 31 30 29 31 23 11 13 30 31 14 31 31 7 23 31 31 14 31 11 25 27 31 15 23 31 19 27 15 7 13 19 28 15 25 15 7 30 27 27 27 15 30 31 15 23 15 14 31 27 30 31 27 19 29 29 31 21 7 31 30 23 30 31 27 27 31 30 29 31 13 15 27 15 27 31 7 31 15 7 22 29 7 29 15 15 31 23 31 29 15 13 15 30 15 23 31 31 23 31 30 23 29 11 7 30 27 11 27 27 25 15 28 23 31 15 19 15 28 31 11 13 11 30 23 30 31 27 31 27 30 31 11 7 29 29 23 29 15 31 31 29 29 22 31 23 15 15 14 11 19 23 30 23 30 27 23 31 19 22 15 29 23 21 21 15 29 30 15 15 31 29 27 30 31 30 31 23 30 29 15 15 29 31 29 21 15 30 23 15 27 11 21 27 22 30 25 31 23 7 23 31 14 23 31 15 29 15 14 23 23 15 31 23 14 31 23 7 23 7 15 31 15 15 30 15 31 13 11 27 13 13 30 31 29 31 31 14 31 15 11 27 28 30 28 31 15 31 15 31 30 27 25 29 30 29 27 15 31 14 31 15 28 30 30 31 31 27 29 27 15 31 15 30 27 31 31 31 31 26 29 29 30 31 31 31 15 31 31 27 26 31 27 25 30 27 11 30 31 15 30 15 31 31 30 30 15 30 30 15 30 27 14 31 30 31 31 31 29 14 31 15 15 31 31 27 27 13 31 28 15 15 30 31 31 31 15 14 31 13 13 31 29 15 31 15 29 30 31 14 31 31 30 27 21 30 31 30 29 27 30 31 23 29 28 15 21 21 15 30 31 29 15 22 15 11 31 25 27 11 30 25 27 27 15 13 15 11 26 31 27 7 22 31 25 26 29 22 30 31 27 15 23 31 27 27 21 29 23 27 30 27 31 27 14 31 7 28 31 15 26 31 15 7 23 30 15 28 31 29 31 25 25 23 31 13 31 27 14 31 15 31 26 15 7 31 27 19 19 23 11 7 30 15 13 15 29 30 7 30 23 15 23 14 31 21 15 15 22 30 31 31 15 31 7 30 15 30 7 29 30 27 26 27 30 29 13 31 22 29 23 31 30 31 27 19 27 22 31 26 15 15 14 30 30 23 15 23 31 26 31 25 22 31 27 11 31 29 25 30 31 27 31 15 23 22 27 30 30 15 19 31 25 29 23 7 31 29 27 23 27 27 29 29 29 28 31 15 31 31 23 31 21 13 21 29 19 31 31 29 23 21 29 31 23 15 31 27 28 31 26 15 27 31 15 26 31 21 7 14 30 31 29 20 30 31 15 31 31 13 30 29 31 29 30 31 29 30 31 23 31 15 27 11 15 22 23 14 27 15 7 15 25 30 29 29 11 23 28 31 31 27 27 31 30 30 15 23 31 22 31 31 31 23 21 30 29 31 29 30 23 31 27 30 31 22 15 15 30 31 15 19 14 31 29 31 13 22 31 31 31 31 25 27 23 25 19 31 11 30 31 27 27 27 22 31 23 26 31 27 19 27 15 30 23 15 27 30 15 29 15 31 7 27 30 31 31 27 15 30 22 27 31 31 31 15 15 14 31 30 31 15 14 29 13 30 31 15 31 31 7 29 30 15 30 23 23 22 31 27 15 27 15 21 28 31 7 15 15 15 23 13 31 13 25 23 31 23 31 22 30 23 30 27 31 11 15 15 31 30 15 25 14 31 22 31 27 26 29 23 31 27 15 31 23 11 23 22 31 21 15 19 29 14 31 23 23 23 7 15 29 15 23 29 30 31 27 14 31 15 23 23 28 30 23 29 31 29 19 27 29 15 23 25 29 31 15 29 15 27 14 31 30 30 31 31 7 30 30 30 31 7 29 31 29 13 29 23 29 31 23 23 15 29 31 31 7 23 31 7 31 15 31 15 26 31 15 13 29 13 30 31 31 29 31 31 13 29 30 30 31 31 15 27 30 27 31 11 28 31 28 15 27 29 27 29 15 13 15 27 15 13 29 25 15 30 31 31 31 15 15 15 31 25 30 15 15 29 30 31 29 31 31 29 27 27 25 25 31 28 27 31 14 31 31 27 31 28 31 15 13 29 27 15 30 31 15 31 15 30 31 15 15 13 11 27 15 30 31 14 31 15 29 28 29 29 31 31 15 31 15 15 31 14 31 31 31 28 31 31 31 29 31 15 31 14 31 30 18 22 30 31 26 23 22 30 25 22 29 26 31 31 19 31 28 30 23 26 31 31 27 23 25 29 23 22 27 31 31 23 27 31 30 30 31 27 29 23 21 22 27 27 22 30 23 30 31 27 26 29 26 31 29 25 23 30 27 29 29 29 27 23 27 23 31 23 23 30 31 26 30 31 29 23 28 31 19 27 23 29 23 23 26 23 27 30 23 28 27 30 27 27 23 23 30 27 23 22 31 31 30 31 23 31 22 29 29 29 23 29 29 29 31 31 23 31 23 30 30 31 31 23 21 31 29 28 23 29 27 31 27 27 31 25 25 22 27 29 23 30 29 23 30 23 19 31 27 29 25 23 21 27 27 31 23 31 23 21 29 23 23 23 31 31 23 30 23 27 27 31 22 23 25 29 27 26 31 31 27 30 31 23 21 22 23 26 31 23 27 22 31 23 31 30 27 26 27 27 31 30 31 23 23 31 28 31 27 19 31 21 31 29 25 27 31 21 31 30 31 31 31 31 31 30 31 22 23 29 21 30 29 31 31 31 23 29 23 31 29 29 29 23 22 31 30 31 31 27 29 30 29 21 23 29 29 31 23 28 31 29 23 23 29 23 29 19 23 23 23 30 31 23 29 22 31 27 19 29 25 29 28 31 31 29 31 31 21 21 23 30 31 31 31 26 23 31 27 23 19 30 31 31 28 31 22 27 19 31 29 29 21 25 29 31 31 31 31 30 31 27 26 31 23 30 30 23 29 18 31 25 31 31 30 31 31 23 23 29 29 22 31 21 27 30 30 31 19 22 23 23 31 31 31 29 23 29 23 30 31 31 30 21 30 30 30 31 31 31 23 30 22 31 26 30 29 27 31 31 28 31 29 31 21 31 29 27 31 29 23 30 31 23 31 23 26 23 23 27 27 19 31 31 23 26 30 31 25 23 25 19 27 31 27 31 26 23 25 23 19 31 30 31 31 31 23 29 29 21 31 23 27 31 27 31 31 21 29 27 29 29 23 31 27 27 31 30 19 29 26 29 30 23 31 25 30 31 27 29 27 19 23 31 31 29 30 31 31 23 31 22 23 31 23 31 30 30 23 28 31 29 29 31 23 23 31 29 29 23 23 28 31 31 22 31 31 30 31 30 27 30 27 27 30 29 29 26 29 29 27 30 29 31 29 27 28 31 29 31 27 30 31 31 29 30 30 31 31 31 26 30 31 29 31 31 30 31 31 28 31 27 30 29 31 31 27 27 31 28 30 31 27 27 31 30 31 29 25 25 26 30 31 27 30 27 30 31 29 30 27 30 31 31 26 30 31 31 31 28 31 27 25 31 31 31 27 31 31 31 31 31 25 27 27 27 31 31 27 31 28 28 30 31 30 31 29 31 29 29 31 31 29 29 31 29 28 31 31 31 30 31 30 31], [5 5 5 5 5]);\r\ntruth = reshape([1 4 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 93 92 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 95 94 91 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 3 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 98 0 0 0 0 99 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 96 97 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 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 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 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0 0 0 0 79 0 0 0 69 22 0 0 0 68 23 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 33 34 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 116 0 0 0 0 117 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 65 0 0 0 0 54 57 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 66 67 0 43 42 55 56 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 36 0 0 41 32 35 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 38 37 0 0 40 39 122 123], [5 5 5 5 5]);\r\nassert(isequal(solve_maze5(maze), truth));","published":true,"deleted":false,"likes_count":5,"comments_count":19,"created_by":134,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":48,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":35,"created_at":"2017-10-12T15:00:57.000Z","updated_at":"2026-03-19T20:06:56.000Z","published_at":"2017-10-16T01:51:01.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eDescription\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe traditional maze is 2-dimensional: the navigator can move in the positive or negative directions along two axes\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ex\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ey\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e. Now imagine, if you will, a 5-dimensional maze. As in the 2-dimensional case, the navigator may only move along one of these directions at any time, and some of the directions are blocked by walls. Your task is to find and give the shortest path through the given maze.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis problem is a generalization of\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/283\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 283\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. If you haven't solved that yet, I would recommend solving it first.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eEncoding\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe maze will be represented by an [\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eM\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e x\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eN\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e x\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eO\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e x\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eP\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e x\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eQ\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e ] matrix.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEach element of the matrix represents a valid location in the maze and the value of each element is a binary-coded representation of the walls, positive directions in which you can not move. If a value reads 0, it means the navigator is permitted to move along any of the five dimensions in the positive direction.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWalls are bi-directional: if a wall exists between two locations, you cannot traverse it in either direction. A skilled navigator must check the destination location's walls if she wishes to move in the negative direction along any dimension.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe start position is at the origin: subscript\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e(1,1,1,1,1)\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe end position is at the furthest extent: subscript\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e(M,N,O,P,Q)\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe output should be a matrix of the same size as the input matrix that lists the steps you need to go through to traverse the maze with the remaining squares being 0. Refer to\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/283\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 283\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e for a 2-D example.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou are\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eNOT\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e guaranteed that there will be only one shortest path for the test cases. If there exist multiple shortest paths, you must represent them all. It can easily be shown that the superposition of two shortest paths will never lead to a multi-valued element in the output matrix.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"}],"term":"tag:\"multidimensional\"","current_player_id":null,"fields":[{"name":"page","type":"integer","callback":null,"default":1,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"per_page","type":"integer","callback":null,"default":50,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"sort","type":"string","callback":null,"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"body","type":"text","callback":null,"default":"*:*","directive":null,"facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":false},{"name":"group","type":"string","callback":null,"default":null,"directive":"group","facet":true,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"difficulty_rating_bin","type":"string","callback":null,"default":null,"directive":"difficulty_rating_bin","facet":true,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"id","type":"integer","callback":null,"default":null,"directive":"id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"tag","type":"string","callback":null,"default":null,"directive":"tag","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"product","type":"string","callback":null,"default":null,"directive":"product","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"created_at","type":"timeframe","callback":{},"default":null,"directive":"created_at","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"profile_id","type":"integer","callback":null,"default":null,"directive":"author_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"created_by","type":"string","callback":null,"default":null,"directive":"author","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"player_id","type":"integer","callback":null,"default":null,"directive":"solver_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"player","type":"string","callback":null,"default":null,"directive":"solver","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"solvers_count","type":"integer","callback":null,"default":null,"directive":"solvers_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"comments_count","type":"integer","callback":null,"default":null,"directive":"comments_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"likes_count","type":"integer","callback":null,"default":null,"directive":"likes_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"leader_id","type":"integer","callback":null,"default":null,"directive":"leader_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"leading_solution","type":"integer","callback":null,"default":null,"directive":"leading_solution","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true}],"filters":[{"name":"asset_type","type":"string","callback":null,"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":"\"cody:problem\"","prepend":true},{"name":"profile_id","type":"integer","callback":{},"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":"author_id","static":null,"prepend":true}],"query":{"params":{"per_page":50,"term":"tag:\"multidimensional\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"multidimensional\"","","\"","multidimensional","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f24a207cb28\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f24a207ca88\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f24a207c128\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f24a207cda8\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f24a207cd08\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f24a207cc68\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f24a207cbc8\u003e":"tag:\"multidimensional\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f24a207cbc8\u003e":"tag:\"multidimensional\""},"queried_facets":{}},"query_backend":{"connection":{"configuration":{"index_url":"http://index-op-v2/solr/","query_url":"http://search-op-v2/solr/","direct_access_index_urls":["http://index-op-v2/solr/"],"direct_access_query_urls":["http://search-op-v2/solr/"],"timeout":10,"vhost":"search","exchange":"search.topic","heartbeat":30,"pre_index_mode":false,"host":"rabbitmq-eks","port":5672,"username":"cody-search","password":"78X075ddcV44","virtual_host":"search","indexer":"amqp","http_logging":"true","core":"cody"},"query_connection":{"uri":"http://search-op-v2/solr/cody/","proxy":null,"connection":{"parallel_manager":null,"headers":{"User-Agent":"Faraday v1.0.1"},"params":{},"options":{"params_encoder":"Faraday::FlatParamsEncoder","proxy":null,"bind":null,"timeout":null,"open_timeout":null,"read_timeout":null,"write_timeout":null,"boundary":null,"oauth":null,"context":null,"on_data":null},"ssl":{"verify":true,"ca_file":null,"ca_path":null,"verify_mode":null,"cert_store":null,"client_cert":null,"client_key":null,"certificate":null,"private_key":null,"verify_depth":null,"version":null,"min_version":null,"max_version":null},"default_parallel_manager":null,"builder":{"adapter":{"name":"Faraday::Adapter::NetHttp","args":[],"block":null},"handlers":[{"name":"Faraday::Response::RaiseError","args":[],"block":null}],"app":{"app":{"ssl_cert_store":{"verify_callback":null,"error":null,"error_string":null,"chain":null,"time":null},"app":{},"connection_options":{},"config_block":null}}},"url_prefix":"http://search-op-v2/solr/cody/","manual_proxy":false,"proxy":null},"update_format":"RSolr::JSON::Generator","update_path":"update","options":{"url":"http://search-op-v2/solr/cody"}}},"query":{"params":{"per_page":50,"term":"tag:\"multidimensional\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"multidimensional\"","","\"","multidimensional","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f24a207cb28\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f24a207ca88\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f24a207c128\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f24a207cda8\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f24a207cd08\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f24a207cc68\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f24a207cbc8\u003e":"tag:\"multidimensional\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f24a207cbc8\u003e":"tag:\"multidimensional\""},"queried_facets":{}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":44378,"difficulty_rating":"hard"}]}}