Cody

# Problem 46040. Solve a Weird Calculator puzzle

Solution 2689316

Submitted on 13 Jul 2020 by Tim
• Size: 72
• This is the leading solution.
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
a = 8; b = 9; n = 2; btn_correct = '*2, -7'; assert(isequal(weirdCalc(a,b,n),btn_correct))

2   Pass
a = 29; b = 30; n = 3; btn_correct = '-7, -7, *2'; assert(isequal(weirdCalc(a,b,n),btn_correct))

3   Pass
a = 54; b = 55; n = 4; btn_correct = '/3, +13, *2, -7'; assert(isequal(weirdCalc(a,b,n),btn_correct))

4   Pass
a = 4; b = 5; n = 5; btn_correct = '*2, -7, *2, +13, /3'; assert(isequal(weirdCalc(a,b,n),btn_correct))

5   Pass
a = 39; b = 40; n = 6; btn_correct = '-7, *2, *2, +13, /3, -7'; assert(isequal(weirdCalc(a,b,n),btn_correct))

6   Pass
a = 152; b = 153; n = 7; btn = split(weirdCalc(a,b,n),', '); x = a; for i = 1:n x= str2num([num2str(x) btn{i}]); end assert(isequal(x,b))

### Community Treasure Hunt

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

Start Hunting!