Cody

# Problem 1870. GJam:2013 World B: MAD Drummer

Solution 317607

Submitted on 11 Sep 2013 by Tobias Schäfer
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
%% tic v=[10 70 ]; exp=0.0000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 60 -15 ans = 0 ```

2   Pass
%% v=[0 10 19 30 ]; exp=0.5000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 10 10 ans = 0.5000 ```

3   Pass
%% v=[2 5 10 15 20 24 ]; exp=0.7500000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 4.5000 12.7500 ans = 0.7500 ```

4   Pass
%% v=[60 62 63 65 67 68 ]; exp=0.3333333; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 1.6667 14.4167 ans = 0.3333 ```

5   Pass
%% v=[0 1 4 9 16 17 24 29 32 33 ]; exp=2.1428571; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 4.1429 13.4286 ans = 2.1429 ```

6   Pass
%% v=[0 3 8 10 18 29 36 43 46 62 ]; exp=5.3333333; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 6.8889 11.5556 ans = 5.3333 ```

7   Pass
%% v=[2 5 7 10 12 15 17 23 24 27 ]; exp=1.5000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 3.0000 13.6250 ans = 1.5000 ```

8   Pass
%% v=[0 3 8 12 14 19 28 30 31 32 ]; exp=3.4375000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 3.6250 13.4375 ans = 3.4375 ```

9   Pass
%% v=[0 1 4 9 16 25 36 49 64 81 ]; exp=10.0000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 9.0000 10.7500 ans = 10 ```

10   Pass
%% v=[0 3 8 12 22 28 38 59 77 80 ]; exp=10.0625000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 9.6250 10.1875 ans = 10.0625 ```

11   Pass
%% v=[31 37 41 47 ]; exp=0.5000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 5.0000 12.7500 ans = 0.5000 ```

12   Pass
%% v=[0 1 2 3 87 95 96 98 99 100 ]; exp=33.9166667; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 16.1667 7.1042 ans = 33.9167 ```

13   Pass
%% v=[8 13 15 20 26 ]; exp=1.1666667; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 4.3333 13.0208 ans = 1.1667 ```

14   Pass
%% v=[49 50 51 52 53 54 55 56 57 ]; exp=0.0000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 1.0000 14.5000 ans = 0 ```

15   Pass
%% v=[94 95 96 97 98 ]; exp=0.0000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 1.0000 14.5000 ans = 0 ```

16   Pass
%% v=[49 50 56 63 73 ]; exp=2.5000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 6.0000 12.2500 ans = 2.5000 ```

17   Pass
%% v=[3 9 11 14 16 24 29 32 34 39 ]; exp=2.5000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 4 13 ans = 2.5000 ```

18   Pass
%% v=[64 66 68 69 ]; exp=0.3333333; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 1.6667 14.2292 ans = 0.3333 ```

19   Pass
%% v=[2 6 9 14 21 73 84 87 90 99 ]; exp=18.9000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 14.2000 7.9313 ans = 18.9000 ```

20   Pass
%% v=[48 49 50 52 53 55 56 57 59 ]; exp=0.4000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 1.4000 14.5500 ans = 0.4000 ```

21   Pass
%% v=[22 23 24 27 30 ]; exp=1.0000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 2 14 ans = 1 ```

22   Pass
%% v=[16 17 22 27 29 30 35 36 39 42 ]; exp=1.8750000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 3.1250 13.4375 ans = 1.8750 ```

23   Pass
%% v=[22 23 24 25 26 27 28 ]; exp=0.0000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 1.0000 14.5000 ans = 0 ```

24   Pass
%% v=[16 18 21 22 24 27 29 31 ]; exp=0.5000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 2 14 ans = 0.5000 ```

25   Pass
%% v=[0 100 ]; exp=0.0000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 100 -35 ans = 0 ```

26   Pass
%% v=[62 63 64 65 66 67 68 69 70 71 ]; exp=0.0000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 1.0000 14.5000 ans = 0 ```

27   Pass
%% v=[12 17 21 22 26 31 ]; exp=1.1666667; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 3.3333 13.4583 ans = 1.1667 ```

28   Pass
%% v=[86 87 88 89 90 91 92 93 94 95 ]; exp=0.0000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 1.0000 14.5000 ans = 0 ```

29   Pass
%% v=[3 11 19 ]; exp=0.0000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 8 11 ans = 0 ```

30   Pass
%% v=[59 60 63 66 68 70 ]; exp=0.6666667; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 2.3333 14.0833 ans = 0.6667 ```

31   Pass
%% v=[78 81 83 ]; exp=0.2500000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 2.5000 13.7500 ans = 0.2500 ```

32   Pass
%% v=[49 51 53 54 56 57 59 ]; exp=0.4000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 1.6000 14.4500 ans = 0.4000 ```

33   Pass
%% v=[5 10 14 19 21 26 27 30 32 33 ]; exp=2.7222222; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 3.1111 13.4444 ans = 2.7222 ```

34   Pass
%% v=[0 2 3 15 18 23 47 49 74 75 ]; exp=11.6250000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 9.2500 10.3750 ans = 11.6250 ```

35   Pass
%% v=[33 36 46 54 56 58 ]; exp=3.5000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 5.5000 12.5000 ans = 3.5000 ```

36   Pass
%% v=[0 3 6 11 13 23 28 31 32 33 ]; exp=3.5000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 4 13 ans = 3.5000 ```

37   Pass
%% v=[62 68 ]; exp=0.0000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 6.0000 12.2500 ans = 0 ```

38   Pass
%% v=[49 50 51 52 ]; exp=0.0000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 1.0000 14.5000 ans = 0 ```

39   Pass
%% v=[60 62 ]; exp=0.0000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 2 14 ans = 0 ```

40   Pass
%% v=[60 63 67 70 72 73 76 ]; exp=1.1000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 2.6000 13.9500 ans = 1.1000 ```

41   Pass
%% v=[90 91 92 93 94 95 96 97 98 99 ]; exp=0.0000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 1.0000 14.5000 ans = 0 ```

42   Pass
%% v=[37 41 ]; exp=0.0000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 4 13 ans = 0 ```

43   Pass
%% v=[0 2 3 5 9 13 14 20 21 27 ]; exp=2.0000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 3.0000 13.7500 ans = 2 ```

44   Pass
%% v=[0 1 2 3 86 87 92 98 99 100 ]; exp=33.4166667; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 16.1667 7.1042 ans = 33.4167 ```

45   Pass
%% v=[80 84 ]; exp=0.0000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 4 13 ans = 0 ```

46   Pass
%% v=[3 5 8 12 67 81 88 90 95 97 ]; exp=20.4166667; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 14.1667 8.0417 ans = 20.4167 ```

47   Pass
%% v=[49 70 ]; exp=0.0000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 21.0000 4.5000 ans = 0 ```

48   Pass
%% v=[0 49 100 ]; exp=0.5000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 50.0000 -9.7500 ans = 0.5000 ```

49   Pass
%% v=[87 88 89 90 91 92 93 94 95 ]; exp=0.0000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 1.0000 14.5000 ans = 0 ```

50   Pass
%% v=[6 8 14 15 18 24 29 33 37 40 ]; exp=1.8333333; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 3.8333 13.0833 ans = 1.8333 ```

51   Pass
%% v=[1 2 5 6 9 11 12 14 15 16 ]; exp=1.0000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 1.7500 14.1250 ans = 1 ```

52   Pass
%% v=[39 42 46 54 61 66 74 ]; exp=2.3333333; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 5.8333 12.3333 ans = 2.3333 ```

53   Pass
%% v=[0 1 2 3 4 96 97 98 99 100 ]; exp=36.4000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 19.2000 5.4000 ans = 36.4000 ```

54   Pass
%% v=[73 74 75 76 77 78 79 ]; exp=0.0000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 1.0000 14.5000 ans = 0 ```

55   Pass
%% v=[0 1 6 13 14 23 24 27 30 33 ]; exp=3.0000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 4 13 ans = 3 ```

56   Pass
%% v=[57 58 59 ]; exp=0.0000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 1.0000 14.5000 ans = 0 ```

57   Pass
%% v=[81 82 83 84 ]; exp=0.0000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 1.0000 14.5000 ans = 0 ```

58   Pass
%% v=[89 91 92 94 ]; exp=0.2500000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 1.5000 14.2500 ans = 0.2500 ```

59   Pass
%% v=[0 3 5 13 15 17 23 28 29 33 ]; exp=2.0000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 4 13 ans = 2 ```

60   Pass
%% v=[33 34 35 36 37 38 39 40 41 42 ]; exp=0.0000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 1.0000 14.5000 ans = 0 ```

61   Pass
%% v=[72 73 74 75 76 77 78 ]; exp=0.0000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 1.0000 14.5000 ans = 0 ```

62   Pass
%% v=[75 76 77 78 79 80 81 82 83 ]; exp=0.0000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 1.0000 14.5000 ans = 0 ```

63   Pass
%% v=[0 4 8 12 16 20 24 28 32 36 ]; exp=0.0000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 4 13 ans = 0 ```

64   Pass
%% v=[0 3 5 6 12 16 18 20 25 26 ]; exp=1.8000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 3.2000 13.6500 ans = 1.8000 ```

65   Pass
%% v=[24 30 36 42 43 45 49 54 56 60 ]; exp=3.0000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 4 13 ans = 3 ```

66   Pass
%% v=[39 40 45 47 ]; exp=1.0000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 3.0000 13.7500 ans = 1 ```

67   Pass
%% v=[1 6 7 11 18 19 20 24 29 35 ]; exp=2.4000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 3.4000 13.3000 ans = 2.4000 ```

68   Pass
%% v=[52 53 55 56 57 58 59 60 62 63 ]; exp=0.4166667; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 1.1667 14.5417 ans = 0.4167 ```

69   Pass
%% v=[24 35 42 47 ]; exp=1.6666667; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 7.6667 11.4167 ans = 1.6667 ```

70   Pass
%% v=[65 67 68 69 70 71 73 75 76 ]; exp=0.6666667; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 1.3333 14.5833 ans = 0.6667 ```

71   Pass
%% v=[0 1 3 9 16 26 44 49 61 81 ]; exp=10.0000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 9.0000 10.7500 ans = 10 ```

72   Pass
%% v=[6 9 12 13 15 16 17 ]; exp=1.1666667; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 1.8333 14.3333 ans = 1.1667 ```

73   Pass
%% v=[0 1 5 13 22 25 31 34 44 49 ]; exp=3.0000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 5.5000 12.5000 ans = 3 ```

74   Pass
%% v=[7 13 24 25 46 57 62 66 88 89 ]; exp=6.1875000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 10.1250 9.9375 ans = 6.1875 ```

75   Pass
%% v=[92 94 96 98 ]; exp=0.0000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 2 14 ans = 0 ```

76   Pass
%% v=[0 1 2 3 5 6 8 ]; exp=0.5000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 1.3333 14.3333 ans = 0.5000 ```

77   Pass
%% v=[84 85 86 87 88 89 90 91 92 ]; exp=0.0000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 1.0000 14.5000 ans = 0 ```

78   Pass
%% v=[1 5 6 9 58 77 87 96 98 100 ]; exp=18.8333333; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 15.1667 7.5417 ans = 18.8333 ```

79   Pass
%% v=[7 13 15 20 21 26 29 35 39 44 ]; exp=1.8125000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 3.8750 13.3125 ans = 1.8125 ```

80   Pass
%% v=[0 51 100 ]; exp=0.5000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 50.0000 -9.7500 ans = 0.5000 ```

81   Pass
%% v=[18 22 23 ]; exp=0.7500000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 2.5000 13.7500 ans = 0.7500 ```

82   Pass
%% v=[35 36 37 38 39 40 41 42 43 ]; exp=0.0000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 1.0000 14.5000 ans = 0 ```

83   Pass
%% v=[1 2 4 5 60 87 93 97 99 100 ]; exp=25.1666667; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 15.8333 7.0833 ans = 25.1667 ```

84   Pass
%% v=[0 10 20 30 40 50 60 70 80 90 ]; exp=0.0000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 10 10 ans = 0 ```

85   Pass
%% v=[72 73 75 77 78 79 ]; exp=0.5000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 1.5000 14.5000 ans = 0.5000 ```

86   Pass
%% v=[87 88 89 90 91 92 93 94 95 ]; exp=0.0000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 1.0000 14.5000 ans = 0 ```

87   Pass
%% v=[12 13 14 16 18 20 24 26 ]; exp=1.0000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 2 14 ans = 1 ```

88   Pass
%% v=[59 64 66 68 70 ]; exp=1.1250000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 2.7500 13.8750 ans = 1.1250 ```

89   Pass
%% v=[46 57 67 ]; exp=0.2500000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 10.5000 10.0000 ans = 0.2500 ```

90   Pass
%% v=[0 9 13 16 17 22 27 38 43 45 ]; exp=3.2857143; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 4.8571 12.8214 ans = 3.2857 ```

91   Pass
%% v=[35 38 40 45 48 51 56 61 66 ]; exp=1.6875000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 3.8750 13.0625 ans = 1.6875 ```

92   Pass
%% v=[0 3 6 9 12 88 91 94 97 100 ]; exp=29.2000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 17.6000 6.2000 ans = 29.2000 ```

93   Pass
%% v=[0 3 4 ]; exp=0.5000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 2 14 ans = 0.5000 ```

94   Pass
%% v=[63 68 70 73 77 ]; exp=0.8333333; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 3.3333 13.3333 ans = 0.8333 ```

95   Pass
%% v=[18 26 36 39 42 43 ]; exp=4.0000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 5.0000 12.7500 ans = 4 ```

96   Pass
%% v=[8 9 14 19 23 25 32 36 37 ]; exp=1.5000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 4 13 ans = 1.5000 ```

97   Pass
%% v=[11 15 17 22 ]; exp=0.7500000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 3.5000 13.2500 ans = 0.7500 ```

98   Pass
%% v=[43 45 47 50 54 58 60 61 65 66 ]; exp=1.4285714; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 2.7143 13.8929 ans = 1.4286 ```

99   Pass
%% v=[18 19 20 21 22 23 24 ]; exp=0.0000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6)

``` ans = 1.0000 14.5000 ans = 0 ```

100   Pass
%% v=[39 44 47 ]; exp=0.5000000; MAD=Drummer(v); assert(abs(MAD-exp)<2e-6) toc

``` ans = 4 13 ans = 0.5000 Elapsed time is 2.423186 seconds. ```