Cody

# Problem 44815. Word Distance - Sum

Solution 2291096

Submitted on 18 May 2020
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
assert(isequal(word_distance_sum('hello'),13))

Brace indexing is not supported for variables of this type. Error in word_distance_sum (line 3) d(k) = sum(abs(diff(lower(str{k})-'a'))); Error in Test1 (line 1) assert(isequal(word_distance_sum('hello'),13))

2   Fail
assert(isequal(word_distance_sum('Hello'),13))

Brace indexing is not supported for variables of this type. Error in word_distance_sum (line 3) d(k) = sum(abs(diff(lower(str{k})-'a'))); Error in Test2 (line 1) assert(isequal(word_distance_sum('Hello'),13))

3   Fail
assert(isequal(word_distance_sum('HELLO'),13))

Brace indexing is not supported for variables of this type. Error in word_distance_sum (line 3) d(k) = sum(abs(diff(lower(str{k})-'a'))); Error in Test3 (line 1) assert(isequal(word_distance_sum('HELLO'),13))

4   Fail
assert(isequal(word_distance_sum('way'),46))

Brace indexing is not supported for variables of this type. Error in word_distance_sum (line 3) d(k) = sum(abs(diff(lower(str{k})-'a'))); Error in Test4 (line 1) assert(isequal(word_distance_sum('way'),46))

5   Fail
assert(isequal(word_distance_sum('Sway'),50))

Brace indexing is not supported for variables of this type. Error in word_distance_sum (line 3) d(k) = sum(abs(diff(lower(str{k})-'a'))); Error in Test5 (line 1) assert(isequal(word_distance_sum('Sway'),50))

6   Pass
[d] = word_distance_sum({'hello','Sway'}); assert(isequal(d(1),13)) assert(isequal(d(2),50))

7   Fail
assert(isequal(word_distance_sum('Matlab'),51))

Brace indexing is not supported for variables of this type. Error in word_distance_sum (line 3) d(k) = sum(abs(diff(lower(str{k})-'a'))); Error in Test7 (line 1) assert(isequal(word_distance_sum('Matlab'),51))

8   Fail
assert(isequal(word_distance_sum('aBCdEfghIJkLmNOPqrStUVwxyZ'),25))

Brace indexing is not supported for variables of this type. Error in word_distance_sum (line 3) d(k) = sum(abs(diff(lower(str{k})-'a'))); Error in Test8 (line 1) assert(isequal(word_distance_sum('aBCdEfghIJkLmNOPqrStUVwxyZ'),25))

9   Fail
assert(isequal(word_distance_sum('qwerty'),44))

Brace indexing is not supported for variables of this type. Error in word_distance_sum (line 3) d(k) = sum(abs(diff(lower(str{k})-'a'))); Error in Test9 (line 1) assert(isequal(word_distance_sum('qwerty'),44))

10   Fail

Brace indexing is not supported for variables of this type. Error in word_distance_sum (line 3) d(k) = sum(abs(diff(lower(str{k})-'a'))); Error in Test10 (line 1) assert(isequal(word_distance_sum('bead'),10))

11   Fail
assert(isequal(word_distance_sum('payday'),87))

Brace indexing is not supported for variables of this type. Error in word_distance_sum (line 3) d(k) = sum(abs(diff(lower(str{k})-'a'))); Error in Test11 (line 1) assert(isequal(word_distance_sum('payday'),87))

12   Fail
assert(isequal(word_distance_sum('bookkeeper'),58))

Brace indexing is not supported for variables of this type. Error in word_distance_sum (line 3) d(k) = sum(abs(diff(lower(str{k})-'a'))); Error in Test12 (line 1) assert(isequal(word_distance_sum('bookkeeper'),58))

13   Pass
[d] = word_distance_sum({'one','TWO','Three','FouR','fiVe','six','sEvEn','EiGHt','NINe','ten'}); assert(isequal(d(1),10)) assert(isequal(d(2),11)) assert(isequal(d(3),35)) assert(isequal(d(4),18)) assert(isequal(d(5),33)) assert(isequal(d(6),25)) assert(isequal(d(7),57)) assert(isequal(d(8),19)) assert(isequal(d(9),19)) assert(isequal(d(10),24))

14   Fail
assert(isequal(word_distance_sum('crazier'),91))

Brace indexing is not supported for variables of this type. Error in word_distance_sum (line 3) d(k) = sum(abs(diff(lower(str{k})-'a'))); Error in Test14 (line 1) assert(isequal(word_distance_sum('crazier'),91))