Cody

# Problem 933. Ordinal numbers

Solution 3642138

Submitted on 13 Nov 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   Pass
assert(isequal(ord(1),'1st'))

2   Pass
assert(isequal(ord(2),'2nd'))

3   Fail
assert(isequal(ord(3),'3rd'))

Assertion failed.

4   Pass
assert(isequal(ord(4),'4th'))

5   Pass
assert(isequal(ord(5),'5th'))

6   Pass
assert(isequal(ord(10),'10th'))

7   Fail
assert(isequal(ord(11),'11th'))

Assertion failed.

8   Fail
assert(isequal(ord(12),'12th'))

Operands to the || and && operators must be convertible to logical scalar values. Error in ord (line 7) elseif str2num(a(end))==2&&find(rem(length(a),2)==1) Error in Test8 (line 1) assert(isequal(ord(12),'12th'))

9   Pass
assert(isequal(ord(13),'13th'))

10   Pass
assert(isequal(ord(14),'14th'))

11   Pass
assert(isequal(ord(15),'15th'))

12   Fail
assert(isequal(ord(82),'82nd'))

Operands to the || and && operators must be convertible to logical scalar values. Error in ord (line 7) elseif str2num(a(end))==2&&find(rem(length(a),2)==1) Error in Test12 (line 1) assert(isequal(ord(82),'82nd'))

13   Pass
assert(isequal(ord(126),'126th'))

14   Fail
assert(isequal(ord(911),'911th'))

Assertion failed.

15   Fail
assert(isequal(ord(2012),'2012th'))

Operands to the || and && operators must be convertible to logical scalar values. Error in ord (line 7) elseif str2num(a(end))==2&&find(rem(length(a),2)==1) Error in Test15 (line 1) assert(isequal(ord(2012),'2012th'))

16   Pass
assert(isequal(ord(4077),'4077th'))

17   Pass
assert(isequal(ord(0),'0th'))

18   Pass
assert(isequal(ord(-101),'-101st'))

### Community Treasure Hunt

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

Start Hunting!