Cody

Solution 1324608

Submitted on 2 Nov 2017 by Elmar Zander
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
expr = "(+ 1 1 1 1 1)"; assert(isequal(eval_lisp(expr), 5));

u = 1 s = ' 1 1 1)' u = 1 s = ' 1 1)' u = 1 s = ' 1)' u = 1 s = ')'

2   Pass
expr = "(+ 1 5)"; assert(isequal(eval_lisp(expr), 6));

u = 5 s = ')'

3   Pass
expr = "(+ 1 1 1 1 1 1 1 1 1 1 1 1 1)"; assert(isequal(eval_lisp(expr), 13));

u = 1 s = ' 1 1 1 1 1 1 1 1 1 1 1)' u = 1 s = ' 1 1 1 1 1 1 1 1 1 1)' u = 1 s = ' 1 1 1 1 1 1 1 1 1)' u = 1 s = ' 1 1 1 1 1 1 1 1)' u = 1 s = ' 1 1 1 1 1 1 1)' u = 1 s = ' 1 1 1 1 1 1)' u = 1 s = ' 1 1 1 1 1)' u = 1 s = ' 1 1 1 1)' u = 1 s = ' 1 1 1)' u = 1 s = ' 1 1)' u = 1 s = ' 1)' u = 1 s = ')'

4   Pass
expr = "(+ 1 2 3 4 5 6 7 8 9 10)"; assert(isequal(eval_lisp(expr), 55));

u = 2 s = ' 3 4 5 6 7 8 9 10)' u = 3 s = ' 4 5 6 7 8 9 10)' u = 4 s = ' 5 6 7 8 9 10)' u = 5 s = ' 6 7 8 9 10)' u = 6 s = ' 7 8 9 10)' u = 7 s = ' 8 9 10)' u = 8 s = ' 9 10)' u = 9 s = ' 10)' u = 10 s = ')'

5   Pass
expr = "(* 1 2 3 4 5 6 7 8 9 10)"; assert(isequal(eval_lisp(expr), 3628800));

u = 2 s = ' 3 4 5 6 7 8 9 10)' u = 3 s = ' 4 5 6 7 8 9 10)' u = 4 s = ' 5 6 7 8 9 10)' u = 5 s = ' 6 7 8 9 10)' u = 6 s = ' 7 8 9 10)' u = 7 s = ' 8 9 10)' u = 8 s = ' 9 10)' u = 9 s = ' 10)' u = 10 s = ')'

6   Pass
expr = "(* (* 10 (+ 1 4)) (+ 10 (/ 12 2 3) 1) 0.1)"; assert(isequal(eval_lisp(expr), 65));

u = 4 s = ')) (+ 10 (/ 12 2 3) 1) 0.1)' u = 5 s = ') (+ 10 (/ 12 2 3) 1) 0.1)' u = 2 s = ' 3) 1) 0.1)' u = 3 s = ') 1) 0.1)' u = 2 s = ' 1) 0.1)' u = 1 s = ') 0.1)' u = 13 s = ' 0.1)' u = 0.1000 s = ')'