Before Dyuman Joshi kindly fixed it, the test suite for problem 60436 contained some syntax errors that made the problem unsolvable, so I took the liberty of fixing that. The task is the same as in that problem: given an integer in base
(passed as a character array), convert it to base
.
What's that you say? There are (well, were) other problems with the test suite of 60436 that I didn't fix here? Nah, can't be!
Solution Stats
Problem Comments
3 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers1
Suggested Problems
-
Project Euler: Problem 9, Pythagorean numbers
1385 Solvers
-
Find the maximum number of decimal places in a set of numbers
3376 Solvers
-
Get the elements of diagonal and antidiagonal for any m-by-n matrix
513 Solvers
-
Convert matrix to 3D array of triangular matrices
134 Solvers
-
1542 Solvers
More from this Author19
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
It looks like there is an issue with the assert statement. The assert function expects the first argument to be a condition that evaluates to a logical value (true or false). However, in this case, it’s comparing two character arrays directly, which is causing the error.
To fix this, you should use the isequal function to compare the output of switchbase with y_correct.
Please fix.
%%
x = '6428367';
b1 = 10;
b2 = 2;
y_correct = '11000100001011011001111';
assert(isequal(switchbase(x,b1,b2),y_correct))
%%
x = '6428367';
b1 = 9;
b2 = 2;
y_correct = '1101001000110110000100'; assert(isequal(switchbase(x,b1,b2),y_correct))
%%
x = '6428367';
b1 = 9;
b2 = 7;
y_correct = '41163052';
assert(isequal(switchbase(x,b1,b2),y_correct))
@George the broken test suite is on purpose. Your mission, should you choose to accept it, is to hack this problem such that you can still pass.