Seems to me that the "best" answer would be tf = logical(mod(n,2)). But I guess the description does not explicitly require logicals, so maybe I am reading too much into the problem. Using logical makes the solution 17 compared to 13 without.
by calling logical function you add extra code.
Test | Status | Code Input and Output |
---|---|---|
1 | Pass |
%%
n = 1;
ans_correct = true;
assert(isequal(is_it_odd(n),ans_correct))
|
2 | Pass |
%%
n = 2;
ans_correct = false;
assert(isequal(is_it_odd(n),ans_correct))
|
3 | Pass |
%%
n = 28;
ans_correct = false;
assert(isequal(is_it_odd(n),ans_correct))
|
4 | Pass |
%%
n = 453;
ans_correct = true;
assert(isequal(is_it_odd(n),ans_correct))
|
5 | Pass |
%%
n = 17;
ans_correct = true;
assert(isequal(is_it_odd(n),ans_correct))
|
6 | Pass |
%%
n = 16;
ans_correct = false;
assert(isequal(is_it_odd(n),ans_correct))
|
Make one big string out of two smaller strings
1070 Solvers
301 Solvers
409 Solvers
739 Solvers
439 Solvers