Cody

Solution 1388829

Submitted on 21 Dec 2017 by suyako
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));

real_s = "+" real_s = 1×2 string array "+" "1" real_s = 1×3 string array "+" "1" "1" real_s = 1×4 string array "+" "1" "1" "1" real_s = 1×5 string array "+" "1" "1" "1" "1" x = 5

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

real_s = "+" real_s = 1×2 string array "+" "1" x = 6

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

real_s = "+" real_s = 1×2 string array "+" "1" real_s = 1×3 string array "+" "1" "1" real_s = 1×4 string array "+" "1" "1" "1" real_s = 1×5 string array "+" "1" "1" "1" "1" real_s = 1×6 string array "+" "1" "1" "1" "1" "1" real_s = 1×7 string array "+" "1" "1" "1" "1" "1" "1" real_s = 1×8 string array "+" "1" "1" "1" "1" "1" "1" "1" real_s = 1×9 string array "+" "1" "1" "1" "1" "1" "1" "1" "1" real_s = 1×10 string array "+" "1" "1" "1" "1" "1" "1" "1" "1" "1" real_s = 1×11 string array "+" "1" "1" "1" "1" "1" "1" "1" "1" "1" "1" real_s = 1×12 string array "+" "1" "1" "1" "1" "1" "1" "1" "1" "1" "1" "1" real_s = 1×13 string array "+" "1" "1" "1" "1" "1" "1" "1" "1" "1" "1" "1" "1" x = 13

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

real_s = "+" real_s = 1×2 string array "+" "1" real_s = 1×3 string array "+" "1" "2" real_s = 1×4 string array "+" "1" "2" "3" real_s = 1×5 string array "+" "1" "2" "3" "4" real_s = 1×6 string array "+" "1" "2" "3" "4" "5" real_s = 1×7 string array "+" "1" "2" "3" "4" "5" "6" real_s = 1×8 string array "+" "1" "2" "3" "4" "5" "6" "7" real_s = 1×9 string array "+" "1" "2" "3" "4" "5" "6" "7" "8" real_s = 1×10 string array "+" "1" "2" "3" "4" "5" "6" "7" "8" "9" x = 55

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

real_s = "*" real_s = 1×2 string array "*" "1" real_s = 1×3 string array "*" "1" "2" real_s = 1×4 string array "*" "1" "2" "3" real_s = 1×5 string array "*" "1" "2" "3" "4" real_s = 1×6 string array "*" "1" "2" "3" "4" "5" real_s = 1×7 string array "*" "1" "2" "3" "4" "5" "6" real_s = 1×8 string array "*" "1" "2" "3" "4" "5" "6" "7" real_s = 1×9 string array "*" "1" "2" "3" "4" "5" "6" "7" "8" real_s = 1×10 string array "*" "1" "2" "3" "4" "5" "6" "7" "8" "9" x = 3628800

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

real_s = "*" real_s = 1×2 string array "*" "*" real_s = 1×3 string array "*" "*" "10" real_s = 1×4 string array "*" "*" "10" "+" real_s = 1×5 string array "*" "*" "10" "+" "1" real_s = 1×5 string array "*" "*" "10" "5" "+" real_s = 1×6 string array "*" "*" "10" "5" "+" "10" real_s = 1×7 string array "*" "*" "10" "5" "+" "10" "/" real_s = 1×8 string array "*" "*" "10" "5" "+" "10" "/" "12" real_s = 1×9 string array "*" "*" "10" "5" "+" "10" "/" "12" "2" x = 65

Suggested Problems

More from this Author56