Cody

Solution 213111

Submitted on 5 Mar 2013 by Tim
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

This solution is outdated. To rescore this solution, log in.

Test Suite

Test Status Code Input and Output
1   Pass
z = rand(2,1)*10; val = rpn(z(1),z(2),'/') assert( val == z(2)/z(1) ) z = rand(2,1)*10; val = rpn(z(1),z(2),'%') assert( val == mod(z(2),z(1)) ) z = rand(2,1)*10; val = rpn(z(1),z(2),'/') assert( val == z(2)/z(1) ) z = rand(2,1)*10; val = rpn(z(1),z(2),'-') assert( val == (z(1)-z(2)) ) z = rand(2,1)*10; val = rpn(z(1),z(2),'+') assert( val == (z(1)+z(2)) ) z = rand(2,1)*10; val = rpn(3,4,'-',5,'+') assert( val == eval('3 - 4 + 5') ) val = rpn(5,1,2,'+',4,'*','+',3,'-') assert( val == eval('5 + ((1+2)*4) - 3') ) val = rpn(55,11,22,'+',44,'*','+',33,'-') assert( val == eval('55 + ((11+22)*44) - 33') ) val = rpn(553,112,221,'+',440,'*','+',30,'-') assert( val == eval('553 + ((112+221)*440) - 30') ) val = rpn(553,112,221,'+',440,'*','+',30,'-') assert( val == eval('553 + ((112+221)*440) - 30') ) z = ceil(rand(1,5)*50); %z = [1,2,3,4,5]; val = rpn(z(1),'+',z(2),'*',z(1),z(3),'-',z(4),z(5),'%','*') q = mod( z(5),z(4))*(((z(1)+z(2))*z(1))-z(3)) assert( val == q )
val = 3.2648 val = 0.5144 val = 3.8159 val = 1.5339 val = 8.6713 val = 4 val = 14 val = 1474 val = 147043 val = 147043 val = 44940 q = 44940