This solution probably doesn't work well for single character inputs though. (For example, when x = 'A'.)
Yeah, i've added said solution to the test suite as the question could include any input
Test | Status | Code Input and Output |
---|---|---|
1 | Pass |
x = 1;
n_correct = 'odd';
assert(isequal(oddornot(x),n_correct))
ans =
'odd'
|
2 | Pass |
x = 12;
n_correct = 'even';
assert(isequal(oddornot(x),n_correct))
ans =
'even'
|
3 | Pass |
x = 467.3;
n_correct = 'error';
assert(isequal(oddornot(x),n_correct))
|
4 | Pass |
x = -911;
n_correct = 'odd';
assert(isequal(oddornot(x),n_correct))
ans =
'odd'
|
5 | Pass |
x = 8230749726348;
n_correct = 'even';
assert(isequal(oddornot(x),n_correct))
ans =
'even'
|
6 | Pass |
x = pi;
n_correct = 'error';
assert(isequal(oddornot(x),n_correct))
|
7 | Fail |
x = 'a';
n_correct = 'error';
assert(isequal(oddornot(x),n_correct))
ans =
'odd'
|
8 | Pass |
x = 'donald';
n_correct = 'error';
assert(isequal(oddornot(x),n_correct))
|
Swap the first and last columns
12411 Solvers
Sum all integers from 1 to 2^n
8414 Solvers
Project Euler: Problem 1, Multiples of 3 and 5
1491 Solvers
Find the largest value in the 3D matrix
1056 Solvers
401 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!