it seems look-up table solutions are becoming a bit of an issue, could you please add a few test cases to discourage this? +1 for random test cases that are a bit harder to trick, for example something like n=randi(100,1,randi(10)); expr = "(+" + string(num2str(n))+ ")"; assert(isequal(eval_lisp(expr), sum(n)));
I think another test case with multiple expressions would be equally useful. Even something as simple as (+ 1 (* 2 3) 4) would prevent some of the look-up solutions. Make some of those values random, and it will work even better.
Good problem, and better than 44374. Precedence is clear.
Nice. I was trying to figure out how to use strtok, but couldn't quite come up with it.
Are you sure that your Test Suite works? I had to change all the double quotes to single quotes.
Double-quoted strings are string literals in MATLAB R2017a+. To convert a string to char array, use the "char" function.
Thank you for that hint about the "char", bmtran. Never would have figured out what was wrong with my solution otherwise...
Clean the List of Names
Project Euler: Problem 3, Largest prime factor
Rotate input square matrix 90 degrees CCW without rot90
Right Triangle Side Lengths (Inspired by Project Euler Problem 39)
Solve the Sudoku Row
Make an N-dimensional Multiplication Table
Roll the Dice!
Give the Shortest Path Through The Maze
Reverse the Words (not letters) of a String
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office