Cody

Problem 233. Reverse the vector

Solution 2643637

Submitted on 2 Jul 2020 by Nayuan Lian
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 = 1; y_correct = 1; assert(isequal(reverseVector(x),y_correct))

a = 1 c = 1 1 c = 1 1 y = 1

2   Pass
x = -10:1; y_correct = 1:-1:-10; assert(isequal(reverseVector(x),y_correct))

a = 1 2 3 4 5 6 7 8 9 10 11 12 c = 1 -10 2 -9 3 -8 4 -7 5 -6 6 -5 7 -4 8 -3 9 -2 10 -1 11 0 12 1 c = 12 1 11 0 10 -1 9 -2 8 -3 7 -4 6 -5 5 -6 4 -7 3 -8 2 -9 1 -10 y = 1 0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10

3   Pass
x = 'able was i ere i saw elba'; y_correct = 'able was i ere i saw elba'; assert(isequal(reverseVector(x),y_correct))

a = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 c = 25×2 char array 'a' 'b' 'l' 'e' ' ' 'w' 'a' 's' '→ ' '↵i' ' ' ' e' '←r' 'e' ' ' 'i' ' ' 's' 'a' 'w' ' ' 'e' 'l' 'b' 'a' c = 25×2 char array 'a' 'b' 'l' 'e' ' ' 'w' 'a' 's' ' ' 'i' ' ' 'e' '←r' ' e' ' ' '↵i' '→ ' 's' 'a' 'w' ' ' 'e' 'l' 'b' 'a' y = 'able was i ere i saw elba'

Suggested Problems

More from this Author1

Community Treasure Hunt

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

Start Hunting!