Cody

Solution 1219653

Submitted on 25 Jun 2017 by Augusto Mazzei
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
x = [5 1 4 2 8]; y_correct = 4; assert(isequal(bubblesort(x),y_correct))

pos = 1 3 pos = 2 3 pos = 3 pos = 2

2   Pass
x = [7 9 17 4 19 3 17 13 20 18]; y_correct = 14; assert(isequal(bubblesort(x),y_correct))

pos = 3 5 7 9 pos = 2 5 7 9 pos = 1 5 7 9 pos = 5 7 9 pos = 4 6 7 9 pos = 3 6 7 9 pos = 2 6 7 9 pos = 1 6 7 9 pos = 6 7 9 pos = 7 9 pos = 6 9 pos = 5 9 pos = 9 pos = 8

3   Pass
x = [73 72 27 56 16 12 21 12 19 1 9 52 44]; y_correct = 54; assert(isequal(bubblesort(x),y_correct))

pos = 1 2 4 5 7 9 12 pos = 2 4 5 7 9 12 pos = 1 3 4 5 7 9 12 pos = 3 4 5 7 9 12 pos = 2 4 5 7 9 12 pos = 4 5 7 9 12 pos = 3 5 7 9 12 pos = 2 5 7 9 12 pos = 1 5 7 9 12 pos = 5 7 9 12 pos = 4 6 7 9 12 pos = 3 6 7 9 12 pos = 2 6 7 9 12 pos = 1 6 7 9 12 pos = 6 7 9 12 pos = 5 7 9 12 pos = 4 7 9 12 pos = 3 7 9 12 pos = 7 9 12 pos = 6 8 9 12 pos = 5 8 9 12 pos = 4 8 9 12 pos = 3 8 9 12 pos = 2 8 9 12 pos = 8 9 12 pos = 7 9 12 pos = 6 9 12 pos = 5 9 12 pos = 4 9 12 pos = 9 12 pos = 8 10 12 pos = 7 10 12 pos = 6 10 12 pos = 5 10 12 pos = 4 10 12 pos = 3 10 12 pos = 2 10 12 pos = 1 10 12 pos = 10 12 pos = 9 11 12 pos = 8 11 12 pos = 7 11 12 pos = 6 11 12 pos = 5 11 12 pos = 4 11 12 pos = 3 11 12 pos = 2 11 12 pos = 11 12 pos = 10 12 pos = 9 12 pos = 12 pos = 11 pos = 10 pos = 9

4   Pass
x = [4 15 2 5 1 5 8 6 12 13 22 7]; y_correct = 18; assert(isequal(bubblesort(x),y_correct))

pos = 2 4 7 11 pos = 1 3 4 7 11 pos = 3 4 7 11 pos = 4 7 11 pos = 3 5 7 11 pos = 2 5 7 11 pos = 1 5 7 11 pos = 5 7 11 pos = 6 7 11 pos = 7 11 pos = 6 8 11 pos = 8 11 pos = 9 11 pos = 11 pos = 10 pos = 9 pos = 8 pos = 7

5   Pass
x = [48 15 16 86 89 29 56 2 59 57 2 6 27 53 91 29 52 32 4 61 67 18 99 12 37 76 71 85 91 9]; y_correct = 180; assert(isequal(bubblesort(x),y_correct))

pos = 1 5 7 9 10 15 17 18 21 23 26 29 pos = 2 5 7 9 10 15 17 18 21 23 26 29 pos = 5 7 9 10 15 17 18 21 23 26 29 pos = 4 6 7 9 10 15 17 18 21 23 26 29 pos = 3 6 7 9 10 15 17 18 21 23 26 29 pos = 6 7 9 10 15 17 18 21 23 26 29 pos = 5 7 9 10 15 17 18 21 23 26 29 pos = 7 9 10 15 17 18 21 23 26 29 pos = 6 8 9 10 15 17 18 21 23 26 29 pos = 5 8 9 10 15 17 18 21 23 26 29 pos = 4 8 9 10 15 17 18 21 23 26 29 pos = 3 8 9 10 15 17 18 21 23 26 29 pos = 2 8 9 10 15 17 18 21 23 26 29 pos = 1 8 9 10 15 17 18 21 23 26 29 pos = 8 9 10 15 17 18 21 23 26 29 pos = 7 9 10 15 17 18 21 23 26 29 pos = 9 10 15 17 18 21 23 26 29 pos = 8 10 15 17 18 21 23 26 29 pos = 7 10 15 17 18 21 23 26 29 pos = 10 15 17 18 21 23 26 29 pos = 9 11 15 17 18 21 23 26 29 pos = 8 11 15 17 18 21 23 26 29 pos = 7 11 15 17 18 21 23 26 29 pos = 6 11 15 17 18 21 23 26 29 pos = 5 11 15 17 18 21 23 26 29 pos = 4 11 15 17 18 21 23 26 29 pos = 3 11 15 17 18 21 23 26 29 pos = 2 11 15 17 18 21 23 26 29 pos = 11 15 17 18 21 23 26 29 pos = 10 12 15 17 18 21 23 26 29 pos = 9 12 15 17 18 21 23 26 29 pos = 8 12 15 17 18 21 23 26 29 pos = 7 12 15 17 18 21 23 26 29 pos = 6 12 15 17 18 21 23 26 29 pos = 5 12 15 17 18 21 23 26 29 pos = 4 12 15 17 18 21 23 26 29 pos = 3 12 15 17 18 21 23 26 29 pos = 12 15 17 18 21 23 26 29 pos = 11 13 15 17 18 21 23 26 29 pos = 10 13 15 17 18 21 23 26 29 pos = 9 13 15 17 18 21 23 26 29 pos = 8 13 15 17 18 21 23 26 29 pos = 7 13 15 17 18 21 23 26 29 pos = 6 13 15 17 18 21 23 26 29 pos = 13 15 17 18 21 23 26 29 pos = 12 15 17 18 21 23 26 29 pos = 11 15 17 18 21 23 26 29 pos = 10 15 17 18 21 23 26 29 pos = 9 15 17 18 21 23 26 29 pos = 15 17 18 21 23 26 29 pos = 14 16 17 18 21 23 26 29 pos = 13 16 17 18 21 23 26 29 pos = 12 16 17 18 21 23 26 29 pos = 11 16 17 18 21 23 26 29 pos = 10 16 17 18 21 23 26 29 pos = 9 16 17 18 21 23 26 29 pos = 8 16 17 18 21 23 26 29 pos = 16 17 18 21 23 26 29 pos = 15 17 18 21 23 26 29 pos = 14 17 18 21 23 26 29 pos = 13 17 18 21 23 26 29 pos = 12 17 18 21 23 26 29 pos = 11 17 18 21 23 26 29 pos = 10 17 18 21 23 26 29 pos = 17 18 21 23 26 29 pos = 16 18 21 23 26 29 pos = 15 18 21 23 26 29 pos = 14 18 21 23 26 29 pos = 13 18 21 23 26 29 pos = 12 18 21 23 26 29 pos = 11 18 21 23 26 29 pos = 10 18 21 23 26 29 pos = 9 18 21 23 26 29 pos = 18 21 23 26 29 pos = 17 19 21 23 26 29 pos = 16 19 21 23 26 29 pos = 15 19 21 23 26 29 pos = 14 19 21 23 26 29 pos = 13 19 21 23 26 29 pos = 12 19 21 23 26 29 pos = 11 19 21 23 26 29 pos = 10 19 21 23 26 29 pos = 9 19 21 23 26 29 pos = 8 19 21 23 26 29 pos = 7 19 21 23 26 29 pos = 6 19 21 23 26 29 pos = 5 19 21 23 26 29 pos = 4 19 21 23 26 29 pos = 3 19 21 23 26 29 pos = 19 21 23 26 29 pos = 18 20 21 23 26 29 pos = 17 20 21 23 26 29 pos = 20 21 23 26 29 pos = 19 21 23 26 29 pos = 18 21 23 26 29 pos = 21 23 26 29 pos = 20 23 26 29 pos = 19 23 26 29 pos = 18 23 26 29 pos = 17 23 26 29 pos = 16 23 26 29 pos = 15 23 26 29 pos = 14 23 26 29 pos = 13 23 26 29 pos = 12 23 26 29 pos = 11 23 26 29 pos = 10 23 26 29 pos = 9 23 26 29 pos = 8 23 26 29 pos = 7 23 26 29 pos = 23 26 29 pos = 22 24 26 29 pos = 21 24 26 29 pos = 20 24 26 29 pos = 19 24 26 29 pos = 18 24 26 29 pos = 17 24 26 29 pos = 16 24 26 29 pos = 15 24 26 29 pos = 14 24 26 29 pos = 13 24 26 29 pos = 12 24 26 29 pos = 11 24 26 29 pos = 10 24 26 29 pos = 9 24 26 29 pos = 8 24 26 29 pos = 7 24 26 29 pos = 6 24 26 29 pos = 5 24 26 29 pos = 24 26 29 pos = 23 25 26 29 pos = 22 25 26 29 pos = 21 25 26 29 pos = 20 25 26 29 pos = 19 25 26 29 pos = 18 25 26 29 pos = 17 25 26 29 pos = 16 25 26 29 pos = 15 25 26 29 pos = 14 25 26 29 pos = 13 25 26 29 pos = 25 26 29 pos = 24 26 29 pos = 23 26 29 pos = 22 26 29 pos = 26 29 pos = 25 27 29 pos = 24 27 29 pos = 23 27 29 pos = 22 27 29 pos = 27 29 pos = 26 28 29 pos = 25 28 29 pos = 24 28 29 pos = 28 29 pos = 29 pos = 28 pos = 27 pos = 26 pos = 25 pos = 24 pos = 23 pos = 22 pos = 21 pos = 20 pos = 19 pos = 18 pos = 17 pos = 16 pos = 15 pos = 14 pos = 13 pos = 12 pos = 11 pos = 10 pos = 9 pos = 8 pos = 7 pos = 6 pos = 5