Cody

Problem 2218. Wayfinding 1 - crossing

Solution 1222763

Submitted on 29 Jun 2017
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Fail
AB = [2 0;0 5]; L = cat(3,... [1 0;2 2],... [-1 4;3 3],... [-3 2;0 2],... [2 3;4 2]... ); n = WayfindingIntersections(AB,L) n_correct = 2; assert(isequal(n,n_correct)); % AB = [ 6 -3 ; 5 2 ]; L = cat(3,... [ 2 2 ; 2 -9 ],... [ -2 3 ; 8 8 ],... [ 7 -1 ; 4 6 ],... [ 7 -3 ; -6 1 ],... [ -6 -6 ; -1 2 ],... [ 5 -8 ; 3 4 ],... [ 3 5 ; -8 -9 ],... [ 8 -8 ; 4 -3 ],... [ -7 9 ; -5 9 ],... [ 6 3 ; 8 3 ],... [ 0 4 ; 9 -2 ],... [ -8 0 ; 4 0 ],... [ 6 8 ; 6 0 ],... [ -6 2 ; -6 9 ],... [ 8 -4 ; 1 -5 ],... [ 5 -1 ; -5 -3 ],... [ -2 -9 ; 6 -5 ],... [ 8 6 ; 6 -7 ],... [ -4 2 ; 5 2 ],... [ 8 6 ; 0 6 ]... ); n = WayfindingIntersections(AB,L) n_correct = 7; assert(isequal(n,n_correct)); % AB = [ -3 -1 ; -3 7 ]; L = cat(3,... [ 9 8 ; 1 6 ],... [ -4 -6 ; -3 9 ],... [ -2 8 ; 7 5 ],... [ -3 5 ; -8 2 ],... [ 1 2 ; 3 5 ],... [ 4 -5 ; -3 -5 ],... [ 8 5 ; -1 -2 ],... [ 4 8 ; 3 5 ],... [ -3 -4 ; 7 8 ],... [ 9 7 ; -1 -3 ]... ); n = WayfindingIntersections(AB,L) n_correct = 1; assert(isequal(n,n_correct)); % AB = [ 5 9 ; -9 0 ]; L = cat(3,... [ 3 -1 ; 1 -2 ],... [ -5 3 ; -3 4 ],... [ -9 -2 ; -3 -7 ],... [ -6 -5 ; -1 -3 ],... [ 4 -3 ; 5 -9 ],... [ -6 -2 ; -4 -4 ],... [ -1 -7 ; -3 -4 ],... [ 0 9 ; 6 3 ],... [ -6 1 ; -7 -8 ],... [ 6 5 ; 6 5 ],... [ 5 6 ; -5 -1 ],... [ 7 9 ; -7 -7 ],... [ -9 -4 ; -2 -3 ],... [ 3 5 ; -2 5 ],... [ -3 -4 ; 5 -6 ]... ); n = WayfindingIntersections(AB,L) n_correct = 0; assert(isequal(n,n_correct)); % AB = [ 6 -3 ; 6 -7 ]; L = cat(3,... [ -7 0 ; -3 0 ],... [ -1 5 ; -8 0 ],... [ 8 -5 ; 1 4 ],... [ -4 -4 ; 7 3 ],... [ 0 0 ; 4 -5 ],... [ -2 -3 ; -4 4 ],... [ 4 -8 ; 2 -5 ],... [ -7 6 ; 6 3 ],... [ -2 -7 ; -3 -8 ],... [ -6 5 ; 8 7 ],... [ 9 -9 ; 5 -9 ],... [ 6 8 ; 4 6 ],... [ 2 7 ; 5 -2 ],... [ -7 -5 ; -1 -7 ],... [ -8 -2 ; 0 -6 ]... ); n = WayfindingIntersections(AB,L) n_correct = 7; assert(isequal(n,n_correct)); % AB = [ 45 25 ; 23 101 ]; L = cat(3,... [ 94 6 ; 2 71 ],... [ 40 -9 ; 51 84 ],... [ -8 97 ; 72 105 ],... [ 18 59 ; 36 88 ],... [ 95 56 ; 10 -6 ],... [ 61 48 ; 96 22 ],... [ 12 100 ; 94 16 ],... [ 103 90 ; 54 106 ],... [ 108 53 ; 34 68 ],... [ 9 20 ; 1 7 ],... [ 76 64 ; -8 106 ],... [ 60 9 ; 51 69 ],... [ 75 62 ; 60 -7 ],... [ 80 -8 ; 70 68 ],... [ 8 30 ; 68 67 ]... ); n = WayfindingIntersections(AB,L) n_correct = 7; assert(isequal(n,n_correct)); % AB = [ -5 -6 ; -2 -6 ]; L = cat(3,... [ -1 -7 ; -7 -1 ],... [ -4 -6 ; -6 -5 ],... [ -7 -2 ; -1 -5 ],... [ -9 -6 ; -4 -4 ],... [ -9 -3 ; -3 -2 ],... [ -2 -1 ; -3 -2 ],... [ -4 -5 ; -6 -9 ],... [ -8 -1 ; -4 -6 ],... [ -1 -5 ; -5 -1 ],... [ -4 -6 ; -2 -5 ]... ); n = WayfindingIntersections(AB,L) n_correct = 6; assert(isequal(n,n_correct)); % AB = [ 1 6 ; 6 7 ]; L = cat(3,... [ 5 8 ; 2 8 ],... [ 6 5 ; 3 2 ],... [ 4 8 ; 6 1 ],... [ 7 2 ; 7 9 ],... [ 1 8 ; 1 2 ],... [ 1 6 ; 1 9 ],... [ 2 6 ; 1 2 ],... [ 3 9 ; 2 4 ],... [ 5 9 ; 2 8 ],... [ 2 8 ; 2 5 ]... ); n = WayfindingIntersections(AB,L) n_correct = 1; assert(isequal(n,n_correct));

Error in solution Line: 9 Column: 14 Expression or statement is incomplete or incorrect.

Suggested Problems

More from this Author31

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!