Cody

Problem 233. Reverse the vector

Solution 2928130

Submitted on 9 Sep 2020 by yu wang
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 1 b = 2 y = [] xi = 1 y = 1

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

a = 1 12 b = 13 y = [] xi = 1 y = 1 xi = 0 y = 1 0 xi = -1 y = 1 0 -1 xi = -2 y = 1 0 -1 -2 xi = -3 y = 1 0 -1 -2 -3 xi = -4 y = 1 0 -1 -2 -3 -4 xi = -5 y = 1 0 -1 -2 -3 -4 -5 xi = -6 y = 1 0 -1 -2 -3 -4 -5 -6 xi = -7 y = 1 0 -1 -2 -3 -4 -5 -6 -7 xi = -8 y = 1 0 -1 -2 -3 -4 -5 -6 -7 -8 xi = -9 y = 1 0 -1 -2 -3 -4 -5 -6 -7 -8 -9 xi = -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 25 b = 26 y = [] xi = 'a' y = 'a' xi = 'b' y = 'ab' xi = 'l' y = 'abl' xi = 'e' y = 'able' xi = ' ' y = 'able ' xi = 'w' y = 'able w' xi = 'a' y = 'able wa' xi = 's' y = 'able was' xi = ' ' y = 'able was ' xi = 'i' y = 'able was i' xi = ' ' y = 'able was i ' xi = 'e' y = 'able was i e' xi = 'r' y = 'able was i er' xi = 'e' y = 'able was i ere' xi = ' ' y = 'able was i ere ' xi = 'i' y = 'able was i ere i' xi = ' ' y = 'able was i ere i ' xi = 's' y = 'able was i ere i s' xi = 'a' y = 'able was i ere i sa' xi = 'w' y = 'able was i ere i saw' xi = ' ' y = 'able was i ere i saw ' xi = 'e' y = 'able was i ere i saw e' xi = 'l' y = 'able was i ere i saw el' xi = 'b' y = 'able was i ere i saw elb' xi = '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!