Cody

Solution 2263773

Submitted on 8 May 2020 by Binbin Qi
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   Pass
filetext = fileread('order_processes.m') assert(isempty(strfind(filetext, 'rand'))) assert(isempty(strfind(filetext, 'fileread'))) assert(isempty(strfind(filetext, 'assert'))) assert(isempty(strfind(filetext, 'echo')))

filetext = 'function d = order_processes(N,P) d = toposort(digraph(P(:,1),P(:,2)),'Order','stable'); d = [d,length(d)+1:N]; end %This code written by profile_id 734801 '

2   Pass
N = 4; P = [1 2; 3 4]; y_correct = [1 2 3 4]; assert(isequal(order_processes(N,P),y_correct))

3   Pass
N = 4; P = [2 1; 2 4]; y_correct = [2 1 3 4]; assert(isequal(order_processes(N,P),y_correct))

4   Pass
N = 4; P = [3 2; 3 1]; y_correct = [3 1 2 4]; assert(isequal(order_processes(N,P),y_correct))

5   Pass
N = 8; P = [3 5; 8 2; 5 1; 4 2; 4 5; 5 2; 6 2; 7 6; 4 6]; y_correct = [3 4 5 1 7 6 8 2]; assert(isequal(order_processes(N,P),y_correct))

6   Pass
N = 77; P = [42 37; 27 29; 59 56; 24 72; 50 40; 18 54; 14 49; 75 70; ... 12 34; 5 29; 56 68; 26 49; 22 2; 40 53; 54 49; 77 14; ... 40 1; 3 1; 33 68; 25 47; 73 63; 33 47; 62 68; 35 49; ... 60 52; 61 49; 74 44; 3 10; 4 2; 38 61; 30 18; 41 54; ... 57 39; 29 14; 58 37; 23 17; 21 39; 18 49; 7 72; 72 44; ... 42 66; 39 68; 51 14; 68 26; 53 41; 74 42; 30 49; 18 53; ... 71 9; 50 54; 67 70; 57 30; 39 66; 36 20; 55 25; 59 44; ... 25 49; 64 67; 56 49; 43 20; 28 74; 50 30; 70 68; 4 21; ... 29 40; 17 40; 55 4; 75 37; 65 69; 12 54; 14 18; 65 40; ... 6 63; 59 52; 63 54; 15 30; 11 66; 5 39; 61 54; 51 18; ... 68 34; 15 62; 61 35; 5 14; 15 63; 37 26; 13 29; 21 29]; y_correct = [3 5 6 7 8 10 11 12 13 15 16 19 22 23 17 24 27 28 31 32 ... 33 36 38 43 20 45 46 48 50 51 55 4 2 21 25 29 47 57 30 39 ... 58 59 56 60 52 61 35 62 64 65 40 1 67 69 71 9 72 73 63 74 ... 42 44 66 75 37 70 68 26 34 76 77 14 18 53 41 54 49 ]; assert(isequal(order_processes(N,P),y_correct))

7   Pass
N = 96; P = [24 33; 83 43; 34 7; 68 88; 29 61; 6 16; 81 71; 29 2; ... 74 5; 35 52; 52 76; 33 92; 49 46; 79 12; 7 59; 57 73; ... 35 58; 88 13; 67 19; 28 53; 43 70; 53 36; 93 7; 86 36; ... 72 62; 23 31; 57 42; 6 35; 11 4; 33 70; 54 10; 75 76; ... 78 59; 42 90; 44 41; 20 87; 40 93; 23 52; 16 15; 63 84; ... 10 59; 38 61; 5 62; 87 71; 31 21; 21 18; 52 93; 1 41; ... 19 41; 67 81; 21 7; 36 74; 58 34; 35 78; 61 75; 84 92; ... 8 90; 33 52; 81 96; 54 21; 71 21; 84 50; 41 93; 86 95; ... 88 26; 74 93; 8 22; 96 7; 82 76; 24 67; 18 34; 30 33; ... 29 16; 50 18; 75 62; 77 17; 56 65; 54 17; 54 48; 53 96; ... 20 18; 18 41; 79 39; 53 34; 11 52; 49 24; 37 84; 63 58; ... 95 41; 28 66; 61 53; 4 19; 49 66; 35 74; 48 76; 41 7; ... 14 54; 1 92; 91 55; 92 15; ]; y_correct = [1 3 6 8 9 11 4 14 20 22 23 25 27 28 29 2 16 30 31 32 ... 35 37 38 40 44 45 47 49 24 33 46 51 52 54 10 48 56 57 42 60 ... 61 53 63 58 64 65 66 67 19 68 69 72 73 75 77 17 78 79 12 39 ... 80 81 82 76 83 43 70 84 50 85 86 36 74 5 62 87 71 21 18 34 ... 88 13 26 89 90 91 55 92 15 94 95 41 93 96 7 59 ]; assert(isequal(order_processes(N,P),y_correct))

8   Pass
N = 49; P = [18 8; 8 42; 42 5; 3 32; 26 36; 16 40; 23 32; 10 13; ... 37 15; 22 11; 23 14; 7 42; 34 28; 20 12; 5 13; 14 26; ... 25 33; 32 28; 12 31; 12 36; 37 31; 19 13; 16 24; 9 32; ... 22 12; 4 17; 18 14; 2 14; 2 23; 23 9; 23 3; ]; y_correct = [1 2 4 6 7 10 16 17 18 8 19 20 21 22 11 12 23 3 9 14 ... 24 25 26 27 29 30 32 33 34 28 35 36 37 15 31 38 39 40 41 42 ... 5 13 43 44 45 46 47 48 49 ]; assert(isequal(order_processes(N,P),y_correct))

9   Pass
N = 33; P = [14 22; 8 1; 27 1; 8 11; 10 22; ]; y_correct = [2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 ... 22 23 24 25 26 27 1 28 29 30 31 32 33 ]; assert(isequal(order_processes(N,P),y_correct))

10   Pass
N = 92; P = [78 42; 69 14; 45 91; 4 46; 57 2; 62 14; 45 8; 15 6; ... 23 21; 67 91; 83 72; 10 4; 34 76; 1 53; 1 30; 15 46; ... 17 19; 42 57; 38 36; 82 92; 3 73; 27 33; 28 79; 54 6; ... 92 2; 7 6; 7 69; 31 16; 84 76; ]; y_correct = [1 3 5 7 9 10 4 11 12 13 15 17 18 19 20 22 23 21 24 25 ... 26 27 28 29 30 31 16 32 33 34 35 37 38 36 39 40 41 43 44 45 ... 8 46 47 48 49 50 51 52 53 54 6 55 56 58 59 60 61 62 63 64 ... 65 66 67 68 69 14 70 71 73 74 75 77 78 42 57 79 80 81 82 83 ... 72 84 76 85 86 87 88 89 90 91 92 2 ]; assert(isequal(order_processes(N,P),y_correct))

11   Pass
N = 100; P = [94 96; 34 13; 33 30; 4 11; 18 66; 19 70; 98 100; 46 4; ... 83 77; 59 41; 17 97; 4 68; 90 28; 31 53; 53 37; 74 20; ... 80 12; 91 30; 2 71; 48 60; 19 7; 78 60; 37 92; 73 30; ... 58 59; 35 78; 51 68; 94 60; 59 94; 2 12; 76 14; 66 16; ... 91 68; 5 57; 32 68; 43 60; 72 85; 75 89; 21 96; 93 41; ... 40 50; 63 10; 44 56; 12 60; 14 29; 43 72; 85 51; 64 86; ... 54 7; 94 30; 11 41; 24 16; 59 60; 20 13; 45 88; 77 79; ... 67 54; 41 1; 18 33; 17 48; 31 60; 59 54; 81 19; 82 97; ... 3 79; 70 1; 42 58; 10 19; 52 98; 74 90; 86 94; 57 55; ... 47 87; 6 43; 90 15; 75 79; 3 51; 12 50; 56 39; 13 1; ... 86 22; 57 73; 23 48; 100 32; 19 85; 32 1; 14 66; 86 87; ... 10 89; 20 12; 59 22; 18 67; 20 32; 41 16; 15 48; 27 59; ... 16 92; 12 66; 62 47; 32 51; ]; y_correct = [2 3 5 6 8 9 17 18 21 23 24 25 26 27 31 33 34 35 36 38 ... 40 42 43 44 45 46 4 11 49 52 53 37 56 39 57 55 58 59 61 62 ... 47 63 10 64 65 67 54 69 71 72 73 74 20 13 75 76 14 29 78 80 ... 12 50 66 81 19 7 70 82 83 77 79 84 85 86 22 87 88 89 90 15 ... 28 48 91 93 41 16 92 94 30 60 95 96 97 98 99 100 32 1 51 68]; assert(isequal(order_processes(N,P),y_correct))

12   Pass
N = 65; P = [33 42; 43 32; 2 37; 10 37; 59 32; 32 49; 17 34; 14 33; ... 7 10; 12 54; 5 18; 1 20; 65 19; 24 36; 20 36; 56 32; ... 42 38; 48 36; 39 32; 24 65; 16 54; 9 17; 27 19; 17 16; ... 26 46; 64 52; 38 34; 59 26; 52 38; 63 50; 28 13; 5 25; ... 10 27; 36 16; 19 64; 23 52; 48 41; 22 38; 54 38; 63 46; ... 44 2; 8 13; 47 65; 36 52; 46 42; 46 38; 51 27; 41 38; ... 2 62; 42 54; 51 3; 1 36; 28 14; 45 19; 6 34; 30 39; ... 20 26; 49 38; 17 14; 2 26; 20 7; 21 33; 20 41; 21 9; ... 37 27; 44 46; 5 34; 53 44; 62 17; 51 62; 50 62; 32 38; ... 41 42; 37 25; 22 65; 3 38; 45 37; 44 13; 3 61; 21 19]; y_correct = [1 4 5 6 8 11 12 15 18 20 7 10 21 9 22 23 24 28 29 30 ... 31 35 39 40 43 45 47 48 36 41 51 3 53 44 2 13 37 25 27 55 ... 56 57 58 59 26 32 49 60 61 63 46 50 62 17 14 16 33 42 54 65 ... 19 64 52 38 34 ]; assert(isequal(order_processes(N,P),y_correct))

13   Pass
N = 26; P = [26 20]; y_correct = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 21 ... 22 23 24 25 26 20]; assert(isequal(order_processes(N,P),y_correct))

14   Pass
N = 12; P = [9 4; 9 7; 6 9; 5 3; 6 11; 2 9; 6 4; 12 4; ... 7 4; 12 6; 2 7; 2 6; 6 7; 1 7; 1 5; 1 10; ... 1 6; 3 6; 10 7; 5 4; 8 6; 5 10; 11 9; 8 7]; y_correct = [1 2 5 3 8 10 12 6 11 9 7 4 ]; assert(isequal(order_processes(N,P),y_correct))

15   Pass
N = 23; P = [19 6; 16 23; 7 14; 21 16; 9 2; 1 6; 7 6; 4 6; ... 15 17; 22 21; 6 17; 18 17; 21 23; 14 17; 10 18; 10 23; ... 20 21; 15 19; 20 5; 22 23; 10 12; 8 17; 2 22; 11 10; ... 4 8; 8 9; 8 5; 7 19; 20 11; 9 17; 13 9; 17 21; ... 8 21; 4 18; 2 18; 13 6; 3 2; 6 21; 4 10; 14 23; ... 19 21; 17 16; 15 18; 10 6; 12 17; 1 18; 12 6; 3 21; ... 20 6; 10 16; 7 18; 8 23; 14 22; 17 23; 7 23; 13 21]; y_correct = [1 3 4 7 8 13 9 2 14 15 19 20 5 11 10 12 6 18 17 22 ... 21 16 23 ]; assert(isequal(order_processes(N,P),y_correct))

16   Pass
N = 86; P = [74 53; 17 66; 84 7; 51 7; 24 57; 58 57; 10 20; 79 65; ... 64 57; 58 39; 43 34; 45 63; 36 7; 4 77; 33 14; 75 19; ... 86 4; 17 76; 54 6; 85 39; 74 39; 75 68; 28 20; 71 74; ... 30 62; 85 65; 24 77; 69 42; 25 66; 40 11; 67 53; 84 6; ... 85 62; 49 35; 54 5; 54 35; 82 64; 49 25; 42 39; 80 57; ... 77 63; 16 46; 8 78; 30 63; 61 73; 75 66; 81 52; 25 63; ... 33 26; 45 12; 9 40; 31 78; 55 30; 34 22; 7 25; 65 63; ... 22 32; 34 52; 9 68; 48 73; 78 65; 73 40; 71 40; 14 68; ... 3 65; 42 40; 15 61; 42 83; 56 74; 53 63; 59 49; 83 72; ... 46 77; 3 10; 6 74; ]; y_correct = [1 2 3 8 9 10 13 15 16 17 18 21 23 24 27 28 20 29 31 33 ... 14 26 36 37 38 41 43 34 22 32 44 45 12 46 47 48 50 51 54 5 ... 55 30 56 58 59 49 35 60 61 67 69 42 70 71 73 40 11 75 19 68 ... 76 78 79 80 81 52 82 64 57 83 72 84 6 7 25 66 74 53 85 39 ... 62 65 86 4 77 63 ]; assert(isequal(order_processes(N,P),y_correct))